diff options
| author | Jeff Carr <[email protected]> | 2024-10-26 08:54:28 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-26 08:54:28 -0500 |
| commit | b4518e8b82df2109b75072c679122e4826b341ef (patch) | |
| tree | a501d4f3c0717a9a5acb51fbcec2b0cc232cda86 /http.go | |
| parent | 9020957ee73741a3f120ff7fd9f9afcb517e02ed (diff) | |
compiles and lists hypervisors
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'http.go')
| -rw-r--r-- | http.go | 68 |
1 files changed, 32 insertions, 36 deletions
@@ -4,9 +4,7 @@ import ( "fmt" "net/http" "strings" - "time" - "go.wit.com/lib/gui/shell" pb "go.wit.com/lib/protobuf/virtbuf" "go.wit.com/lib/virtigoxml" "go.wit.com/log" @@ -24,23 +22,19 @@ func okHandler(w http.ResponseWriter, r *http.Request) { // is the cluster running what it should? if tmp == "/droplets" { - for _, d := range me.droplets { - if d.pb.StartState != pb.DropletState_ON { + for _, d := range me.cluster.Droplets { + if d.StartState != pb.DropletState_ON { continue } - dur := time.Since(d.lastpoll) // Calculate the elapsed time - var hname string - if d.h == nil { - hname = "" - } else { - hname = d.h.pb.Hostname - } - if d.CurrentState != pb.DropletState_ON { - fmt.Fprintln(w, "BAD STATE ", d.pb.Hostname, hname, "(", d.pb.StartState, "vs", d.CurrentState, ")", shell.FormatDuration(dur)) - } else { - dur := time.Since(d.lastpoll) // Calculate the elapsed time - fmt.Fprintln(w, "GOOD STATE ON", d.pb.Hostname, hname, shell.FormatDuration(dur)) - } + /* + dur := time.Since(d.Lastpoll) // Calculate the elapsed time + if d.CurrentState != pb.DropletState_ON { + fmt.Fprintln(w, "BAD STATE ", d.Hostname, hname, "(", d.StartState, "vs", d.CurrentState, ")", shell.FormatDuration(dur)) + } else { + dur := time.Since(d.lastpoll) // Calculate the elapsed time + fmt.Fprintln(w, "GOOD STATE ON", d.Hostname, hname, shell.FormatDuration(dur)) + } + */ } return } @@ -81,26 +75,28 @@ func okHandler(w http.ResponseWriter, r *http.Request) { log.Info("Handling URL:", tmp, "cluster is not right yet", s) fmt.Fprintln(w, s) } - for _, h := range me.hypers { - url := "http://" + h.pb.Hostname + ":2520/kill" - dur := time.Since(h.lastpoll) // Calculate the elapsed time - if dur > 90*time.Second { - h.RestartDaemon() - continue + /* + for _, h := range me.hypers { + url := "http://" + h.pb.Hostname + ":2520/kill" + dur := time.Since(h.lastpoll) // Calculate the elapsed time + if dur > 90*time.Second { + h.RestartDaemon() + continue + } + if h.killcount != 0 { + log.Info("KILL count =", h.killcount, "FOR", h.pb.Hostname, dur, "curl", url) + } + if h.killcount > 10 { + log.Info("KILL count is greater than 10 for host", h.pb.Hostname, dur, "curl", url) + } + // l := shell.FormatDuration(dur) + // log.Warn("HOST =", h.pb.Hostname, "Last poll =", l) + //if d.pb.StartState != "ON" { + // continue + //} + // dur := time.Since(d.lastpoll) // Calculate the elapsed time } - if h.killcount != 0 { - log.Info("KILL count =", h.killcount, "FOR", h.pb.Hostname, dur, "curl", url) - } - if h.killcount > 10 { - log.Info("KILL count is greater than 10 for host", h.pb.Hostname, dur, "curl", url) - } - // l := shell.FormatDuration(dur) - // log.Warn("HOST =", h.pb.Hostname, "Last poll =", l) - //if d.pb.StartState != "ON" { - // continue - //} - // dur := time.Since(d.lastpoll) // Calculate the elapsed time - } + */ return } |
