summaryrefslogtreecommitdiff
path: root/app/fetch.go
diff options
context:
space:
mode:
authorHorus32015-05-05 22:41:27 +0200
committerHorus32015-05-05 22:41:27 +0200
commitf71b90582c713e528fb731ded8ded8d8b599c031 (patch)
tree97f8a51ecae187477672e4e7f46ed84444447fd5 /app/fetch.go
parent39ae1e288e94871ea7fe41976080afdb503950bc (diff)
downloadstatuspage-f71b90582c713e528fb731ded8ded8d8b599c031.tar.gz
Fixed IndexOutOfBonds runtime panic.HEADmaster
Diffstat (limited to 'app/fetch.go')
-rw-r--r--app/fetch.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/fetch.go b/app/fetch.go
index fc457f7..799fb58 100644
--- a/app/fetch.go
+++ b/app/fetch.go
@@ -16,6 +16,7 @@ func healthCheck() {
func CheckPages(h []Host) []Host {
wentWrong := false
+ hostName := ""
for k, v := range h {
if !h[k].Monitored {
@@ -26,9 +27,11 @@ func CheckPages(h []Host) []Host {
h[k].Status = "Error"
h[k].StatusCode = 0
h[k].Success = false
- h[k].Monitored = false
+ //h[k].Monitored = false
h[k].Reason = fmt.Sprintf("%v", err)
h[k].Class = "danger"
+ hostName = h[k].Host
+ wentWrong = true
} else {
h[k].Status = resp.Status
h[k].StatusCode = int64(resp.StatusCode)
@@ -40,6 +43,8 @@ func CheckPages(h []Host) []Host {
h[k].Success = false
h[k].Class = "danger"
h[k].Monitored = true
+ wentWrong = true
+ hostName = h[k].Host
}
h[k].Reason = ""
}
@@ -48,13 +53,14 @@ func CheckPages(h []Host) []Host {
if wentWrong {
u := []User{}
Db.Find(&u)
- SendEmail(u, h)
+ SendEmail(u, h, hostName)
}
return h
}
func CheckAllPages(h []Host) []Host {
wentWrong := false
+ hostName := ""
for k, v := range h {
if resp, _, err := HttpGet(v.Url); err != nil {
@@ -65,6 +71,7 @@ func CheckAllPages(h []Host) []Host {
h[k].Reason = fmt.Sprintf("%v", err)
h[k].Class = "danger"
wentWrong = true
+ hostName = h[k].Host
} else {
h[k].Status = resp.Status
h[k].StatusCode = int64(resp.StatusCode)
@@ -74,6 +81,9 @@ func CheckAllPages(h []Host) []Host {
} else {
h[k].Success = false
h[k].Class = "danger"
+ h[k].Monitored = true
+ wentWrong = true
+ hostName = h[k].Host
}
h[k].Reason = ""
}
@@ -82,7 +92,7 @@ func CheckAllPages(h []Host) []Host {
if wentWrong {
u := []User{}
Db.Find(&u)
- SendEmail(u, h)
+ SendEmail(u, h, hostName)
}
return h
}