From 268cec143ae544d8b6abed55b2f84570b51ea030 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 13 Oct 2024 01:38:35 -0500 Subject: [PATCH] more accurate totals Signed-off-by: Jeff Carr --- poll.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/poll.go b/poll.go index 8eeb624..b25e810 100644 --- a/poll.go +++ b/poll.go @@ -76,6 +76,9 @@ func clusterHealthy() (bool, string) { var total int var working int var failed int + var missing int + var unknown int + for _, d := range me.droplets { total += 1 if d.State != "ON" { @@ -84,6 +87,7 @@ func clusterHealthy() (bool, string) { dur := time.Since(d.lastpoll) // Calculate the elapsed time if d.CurrentState == "" { // log.Info("SKIP. hostname has not been polled yet", d.Hostname, d.hname) + unknown += 1 continue } if d.CurrentState != "ON" { @@ -102,6 +106,7 @@ func clusterHealthy() (bool, string) { l := shell.FormatDuration(dur) if l == "" { log.Info("DUR IS EMPTY", dur) + missing += 1 continue } working += 1 @@ -110,8 +115,12 @@ 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 missing > 0 { + summary += fmt.Sprintf("missing = %d ", missing) + } + if unknown > 0 { + summary += fmt.Sprintf("unknown = %d ", unknown) } if failed > 0 { summary += fmt.Sprintf("failed = %d ", failed)