summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
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