summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'http.go')
-rw-r--r--http.go38
1 files changed, 37 insertions, 1 deletions
diff --git a/http.go b/http.go
index abf7983..cb3f35a 100644
--- a/http.go
+++ b/http.go
@@ -7,6 +7,7 @@ import (
"go.wit.com/lib/virtigoxml"
"go.wit.com/log"
+ pb "go.wit.com/lib/protobuf/virtbuf"
)
// remove '?' part and trailing '/'
@@ -22,7 +23,42 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
// is the cluster running what it should?
if tmp == "/droplets" {
for _, d := range me.cluster.Droplets {
- fmt.Fprintln(w, "", d.Hostname, "(", d.StartState, "vs", d.CurrentState, ")")
+ var msg string
+ if d.StartState == pb.DropletState_ON {
+ msg = "(should be on)"
+ }
+ switch d.CurrentState {
+ case pb.DropletState_ON:
+ fmt.Fprintln(w, d.Hostname, "ON")
+ case pb.DropletState_OFF:
+ fmt.Fprintln(w, d.Hostname, msg)
+ default:
+ fmt.Fprintln(w, d.Hostname, "? state:", d.CurrentState, msg)
+ }
+ }
+ return
+ }
+
+ // show only what droplets should be running but are missing
+ if tmp == "/missing" {
+ var count int
+ var missing int
+ for _, d := range me.cluster.Droplets {
+ if d.StartState != pb.DropletState_ON {
+ continue
+ }
+ count += 1
+ if d.CurrentState == pb.DropletState_ON {
+ continue
+ }
+ missing += 1
+ fmt.Fprintln(w, d.Hostname, "current state:", d.CurrentState)
+ }
+ if missing == 0 {
+ fmt.Fprintln(w, "all", count, "droplets set to run are running")
+ } else {
+ fmt.Fprintln(w, missing, "droplets missing")
+ fmt.Fprintln(w, count, "droplets should be running")
}
return
}