more http options
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
2e8281d067
commit
7837182d53
12
Makefile
12
Makefile
|
@ -74,3 +74,15 @@ git-clone:
|
|||
go-clone --recursive --go-src --no-work go.wit.com/apps/virtigo
|
||||
go-clone --recursive --go-src --no-work go.wit.com/apps/gowebd
|
||||
go-clone --recursive --go-src --no-work go.wit.com/lib/daemons/virtigod
|
||||
|
||||
http-uptime:
|
||||
curl --silent http://localhost:8080/uptime
|
||||
|
||||
http-droplets:
|
||||
curl --silent http://localhost:8080/droplets
|
||||
|
||||
http-missing:
|
||||
curl --silent http://localhost:8080/missing
|
||||
|
||||
http-dumplibvirtxml:
|
||||
curl --silent http://localhost:8080//dumplibvirtxml
|
||||
|
|
1
event.go
1
event.go
|
@ -84,7 +84,6 @@ func findDroplet(name string) *pb.Droplet {
|
|||
return nil
|
||||
}
|
||||
|
||||
|
||||
func Start(name string) (bool, string) {
|
||||
var result string
|
||||
|
||||
|
|
38
http.go
38
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue