diff options
| author | Jeff Carr <[email protected]> | 2024-10-22 18:19:21 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-22 18:19:21 -0500 |
| commit | b1a943fa3dff6a9a0d7f802111334be7d1175492 (patch) | |
| tree | 9bfc53db8a75466c51b0543a23f81285e3ab72eb /http.go | |
| parent | 3ba9a5da209bf070a268b20df48a5a41f7b31109 (diff) | |
compiles and runs
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'http.go')
| -rw-r--r-- | http.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -27,11 +27,17 @@ func okHandler(w http.ResponseWriter, r *http.Request) { 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 != "ON" { - fmt.Fprintln(w, "BAD STATE ", d.pb.Hostname, d.hname, "(", d.pb.StartState, "vs", d.CurrentState, ")", shell.FormatDuration(dur)) + 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, d.hname, shell.FormatDuration(dur)) + fmt.Fprintln(w, "GOOD STATE ON", d.pb.Hostname, hname, shell.FormatDuration(dur)) } } return |
