summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-22 18:19:21 -0500
committerJeff Carr <[email protected]>2024-10-22 18:19:21 -0500
commitb1a943fa3dff6a9a0d7f802111334be7d1175492 (patch)
tree9bfc53db8a75466c51b0543a23f81285e3ab72eb /http.go
parent3ba9a5da209bf070a268b20df48a5a41f7b31109 (diff)
compiles and runs
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'http.go')
-rw-r--r--http.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/http.go b/http.go
index be4a8c0..b8f8758 100644
--- a/http.go
+++ b/http.go
@@ -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