summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-12 12:45:43 -0500
committerJeff Carr <[email protected]>2024-10-12 12:45:43 -0500
commite94b4d6626fafb20da118eb8b17e661928c2b5da (patch)
treee913fb22aadd8fcb9523d5a6cf3712b9464b63bd /http.go
parent487c6fd11c2746a71fee1a6b562e41fbb2486382 (diff)
first basic check to tell if the cluster is healthy
Signed-off-by: Jeff Carr <[email protected]>
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