display status and uptime

This commit is contained in:
Jeff Carr 2025-02-23 17:01:22 -06:00
parent 01d7e92cdb
commit 30a5eb56a2
3 changed files with 23 additions and 2 deletions

View File

@ -20,7 +20,7 @@ import (
func debug() { func debug() {
for { for {
time.Sleep(90 * time.Second) time.Sleep(90 * time.Second)
log.Info("TODO: virtigo scan here. repo count =") // log.Info("TODO: use this?")
} }
} }
@ -108,6 +108,23 @@ func drawWindow(win *gadgets.BasicWindow) {
d := me.cluster.GetDropletsPB() d := me.cluster.GetDropletsPB()
testWin, _ = makeDropletsWindow(d) testWin, _ = makeDropletsWindow(d)
}) })
grid.NextRow()
me.status = grid.NewLabel("cur status")
grid.NextRow()
me.lastuptime = grid.NewLabel("last uptime")
grid.NextRow()
grid.NewButton("uptime", func() {
updateUptimeGui("kuma uptime should update this")
})
}
func updateUptimeGui(uptime string) {
me.status.SetLabel(uptime)
datestamp := time.Now().Format("2006-01-02 15:04:03")
me.lastuptime.SetLabel("last uptime at " + datestamp)
} }
func makeDropletsWindow(pb *virtpb.Droplets) (*GenericWindow, *virtpb.DropletsTable) { func makeDropletsWindow(pb *virtpb.Droplets) (*GenericWindow, *virtpb.DropletsTable) {

View File

@ -31,7 +31,9 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} }
if route == "/uptime" { if route == "/uptime" {
ok, s := uptimeCheck() ok, s := uptimeCheck()
log.Info(s) fmt.Fprint(w, s)
// log.Info(s)
updateUptimeGui(s)
if ok { if ok {
// log.Info("Handling URL:", route, "cluster is ok") // log.Info("Handling URL:", route, "cluster is ok")
} else { } else {

View File

@ -34,6 +34,8 @@ type virtigoT struct {
unstableTimeout time.Duration // how long a droplet can be unstable until it's declared dead unstableTimeout time.Duration // how long a droplet can be unstable until it's declared dead
clusterStableDuration time.Duration // how long the cluster must be stable before new droplets can be started clusterStableDuration time.Duration // how long the cluster must be stable before new droplets can be started
missingDropletTimeout time.Duration // how long a droplet can be missing for missingDropletTimeout time.Duration // how long a droplet can be missing for
status *gui.Node // the cluster status
lastuptime *gui.Node // the last time uptime was checked by Kuma
} }
// the stuff that is needed for a hypervisor // the stuff that is needed for a hypervisor