summaryrefslogtreecommitdiff
path: root/poll.go
diff options
context:
space:
mode:
Diffstat (limited to 'poll.go')
-rw-r--r--poll.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/poll.go b/poll.go
index dc9d171..8eeb624 100644
--- a/poll.go
+++ b/poll.go
@@ -73,9 +73,11 @@ func findDroplet(name string) *DropletT {
// that is intended to be sent to an uptime monitor like Kuma
func clusterHealthy() (bool, string) {
var good bool = true
+ var total int
var working int
var failed int
for _, d := range me.droplets {
+ total += 1
if d.State != "ON" {
continue
}
@@ -87,6 +89,7 @@ func clusterHealthy() (bool, string) {
if d.CurrentState != "ON" {
log.Info("BAD STATE", d.State, d.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur))
good = false
+ failed += 1
} else {
dur := time.Since(d.lastpoll) // Calculate the elapsed time
if dur > time.Minute {
@@ -106,12 +109,14 @@ func clusterHealthy() (bool, string) {
}
}
var summary string = "("
+ summary += fmt.Sprintf("total = %d ", total)
if working > 0 {
- summary += fmt.Sprintf("working = %d", working)
+ summary += fmt.Sprintf("working = %d ", working)
}
if failed > 0 {
- summary += fmt.Sprintf("failed = %d", failed)
+ summary += fmt.Sprintf("failed = %d ", failed)
}
+ summary = strings.TrimSpace(summary)
summary += ")"
if good {
return good, "GOOD=true " + summary