show totals

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-13 01:33:32 -05:00
parent eddd658b7f
commit 3739671503
2 changed files with 14 additions and 2 deletions

View File

@ -1,9 +1,16 @@
package main
import (
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
func (d *DropletT) Start() {
log.Info("a new virtual machine is running")
}
func (h *HyperT) RestartDaemon() {
url := "http://" + h.Hostname + ":2520/kill"
s := shell.Wget(url)
log.Info("EVENT RestartDaemon", url, s)
}

View File

@ -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