google / seesaw

Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform.
Apache License 2.0
5.63k stars 511 forks source link

lib ipvs get services failed. #23

Closed soarpenguin closed 8 years ago

soarpenguin commented 8 years ago
package main

import (
    "fmt"
    "github.com/google/seesaw/ipvs"
)

func main() {
    fmt.Printf("start.............\n")
    fmt.Printf("%v\n", ipvs.Version())
    srvs, err := ipvs.GetServices()
    if err != nil {
        fmt.Printf("%s\n", err.Error())
    }

    for _, srv := range srvs {
        fmt.Printf("%s\n", srv)
    }
    fmt.Printf("end.............\n")
}

Hello, i use above code to get ipvs services, but failed, get none. the stdout is:

start.............
0.0.0
end.............

i can use ipvsadm get some services:

$ ipvsadm -ln

TCP  10.10.19.18:80 rr
  -> 10.10.35.48:80              Route   100    0          0         
  -> 10.10.35.49:80              Route   100    0          0         
TCP  10.10.19.19:80 rr
  -> 10.10.26.20:80             Route   100    0          0         
  -> 10.10.26.21:80             Route   100    0          1         
  -> 10.10.26.22:80             Route   100    0          0         
  -> 10.10.26.23:80             Route   100    1          0  
luizbafilho commented 8 years ago

@soarpenguin You need to Initialize first: ipvs.Init()

soarpenguin commented 8 years ago

@luizbafilho tks! It's ok now.