diff options
| author | Jeff Carr <[email protected]> | 2024-10-13 01:13:19 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-13 01:13:19 -0500 |
| commit | eddd658b7f4f14083e801d9bd0fa1642455d7380 (patch) | |
| tree | d7747e38287d0ca777784d6d0257dce6b2d837f9 /poll.go | |
| parent | 7a4bc0b5d6fea7f8d036b36279564dc065e74301 (diff) | |
start a tally of working, totals, not working, etc
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'poll.go')
| -rw-r--r-- | poll.go | 26 |
1 files changed, 23 insertions, 3 deletions
@@ -1,6 +1,7 @@ package main import ( + "fmt" "strings" "time" @@ -68,8 +69,12 @@ func findDroplet(name string) *DropletT { return nil } -func clusterHealthy() bool { - var good = true +// check the state of the cluster and return a string +// that is intended to be sent to an uptime monitor like Kuma +func clusterHealthy() (bool, string) { + var good bool = true + var working int + var failed int for _, d := range me.droplets { if d.State != "ON" { continue @@ -88,13 +93,28 @@ func clusterHealthy() bool { log.Info("GOOD STATE MISSING", d.Hostname, d.hname, shell.FormatDuration(dur)) good = false d.CurrentState = "MISSING" + failed += 1 + continue } l := shell.FormatDuration(dur) if l == "" { log.Info("DUR IS EMPTY", dur) + continue } + working += 1 // log.Info("GOOD STATE ON", d.Hostname, d.hname, "dur =", l) } } - return good + var summary string = "(" + if working > 0 { + summary += fmt.Sprintf("working = %d", working) + } + if failed > 0 { + summary += fmt.Sprintf("failed = %d", failed) + } + summary += ")" + if good { + return good, "GOOD=true " + summary + } + return good, "GOOD=false " + summary } |
