uptime ignores unresponsive hosts

This commit is contained in:
Jeff Carr 2025-03-21 19:30:02 -05:00
parent 687e97ab09
commit b5925dcdce
2 changed files with 11 additions and 4 deletions

10
http.go
View File

@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/http"
"strings"
"time"
"go.wit.com/log"
)
@ -83,10 +84,13 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
}
var count int
var bad int
all := me.machines.All()
for all.Scan() {
m := all.Next()
for m := range me.machines.IterAll() {
count += 1
if m.SinceLastUpdate() > 10*time.Minute {
// skip machines that have not been updated in the last 10 minutes
log.Info("ignoring old machine", m.Hostname)
continue
}
if findVersion(m, "zood") != me.zood.version {
bad += 1
}

View File

@ -123,7 +123,10 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
t.AddMemory()
t.AddCpus()
t.AddStringFunc("sMB", func(m *zoopb.Machine) string {
return fmt.Sprintf("%d mb", m.Memory/(1024*1024))
if m.Memory/(1024*1024) > 10000 {
return fmt.Sprintf("%4d G", m.Memory/(1024*1024*1024))
}
return fmt.Sprintf("%4d M", m.Memory/(1024*1024))
})
t.AddStringFunc("zood", func(m *zoopb.Machine) string {