summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'http.go')
-rw-r--r--http.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/http.go b/http.go
index e4c9401..772d358 100644
--- a/http.go
+++ b/http.go
@@ -6,8 +6,8 @@ import (
"strings"
"time"
- "go.wit.com/log"
"go.wit.com/lib/gui/shell"
+ "go.wit.com/log"
)
// remove '?' part and trailing '/'
@@ -30,7 +30,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
return
}
- if tmp == "/vms" {
+ // list all the droplets
+ if tmp == "/droplets" {
for _, d := range me.droplets {
dur := time.Since(d.lastpoll) // Calculate the elapsed time
fmt.Fprintln(w, d.Hostname, d.hname, shell.FormatDuration(dur))
@@ -38,6 +39,30 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
return
}
+ // is the cluster running what it should?
+ if tmp == "/good" {
+ 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" {
+ fmt.Fprintln(w, "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
+ fmt.Fprintln(w, "GOOD STATE ON", d.Hostname, d.hname, shell.FormatDuration(dur))
+ }
+ }
+ if good {
+ fmt.Fprintln(w, "GOOD=true")
+ } else {
+ fmt.Fprintln(w, "GOOD=false")
+ }
+ return
+ }
+
if tmp == "/favicon.ico" {
writeFile(w, "ipv6.png")
return