state changes if droplet reboots
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
e94b4d6626
commit
58ff2a2412
6
http.go
6
http.go
|
@ -68,7 +68,11 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if tmp == "/uptime" {
|
if tmp == "/uptime" {
|
||||||
writeFile(w, "uptime.html")
|
if clusterHealthy() {
|
||||||
|
fmt.Fprintln(w, "GOOD=true")
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(w, "GOOD=false")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
poll.go
28
poll.go
|
@ -63,3 +63,31 @@ func findDroplet(name string) *DropletT {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clusterHealthy() bool {
|
||||||
|
var good = true
|
||||||
|
for _, d := range me.droplets {
|
||||||
|
if d.State != "ON" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||||
|
if d.CurrentState != "ON" {
|
||||||
|
log.Info("BAD STATE ", d.Hostname, "State =", d.State, "CurrentState =", d.CurrentState, shell.FormatDuration(dur))
|
||||||
|
good = false
|
||||||
|
} else {
|
||||||
|
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||||
|
if dur > time.Minute {
|
||||||
|
log.Info("GOOD STATE MISSING", d.Hostname, d.hname, shell.FormatDuration(dur))
|
||||||
|
good = false
|
||||||
|
d.CurrentState = "MISSING"
|
||||||
|
}
|
||||||
|
log.Info("GOOD STATE ON", d.Hostname, d.hname, shell.FormatDuration(dur))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if good {
|
||||||
|
log.Info("GOOD=true")
|
||||||
|
} else {
|
||||||
|
log.Info("GOOD=false")
|
||||||
|
}
|
||||||
|
return good
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue