func printFailoverIp(failoverIp, localIp string) { var failover api.Failover if err := api.Get("/failover/"+failoverIp, &failover); err != nil { fatal(err) } a := net.ParseIP(failover.Netmask) _, bits := net.IPv4Mask(a[0], a[1], a[2], a[3]).Size() fmt.Printf(format, failover.Ip, bits, failover.Active_server_ip, failover.Server_ip, failover.Server_number, dutyMark(failover.Active_server_ip.String(), localIp)) }
func checkDutyStatus(failoverIp, localIp string) { var failover api.Failover if err := api.Get("/failover/"+failoverIp, &failover); err != nil { fatal(err) } if failover.Active_server_ip.String() == localIp { os.Exit(0) } os.Exit(255) }
func printAllFailoverIPs(failoverIp, localIp string) { var ips []api.Failover if err := api.Get("/failover", &ips); err != nil { fatal(err) } for _, d := range ips { a := net.ParseIP(d.Netmask) _, bits := net.IPv4Mask(a[0], a[1], a[2], a[3]).Size() mark := ' ' if d.Ip.String() == failoverIp { mark = dutyMark(d.Active_server_ip.String(), localIp) } fmt.Printf(format, d.Ip, bits, d.Active_server_ip, d.Server_ip, d.Server_number, mark) } }