diff options
Diffstat (limited to 'app/fetch.go')
| -rw-r--r-- | app/fetch.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/fetch.go b/app/fetch.go index 18721fc..f4be5c0 100644 --- a/app/fetch.go +++ b/app/fetch.go @@ -15,6 +15,7 @@ func healthCheck() { } func CheckPages(h []Host) []Host { + wentWrong := false for k, v := range h { if !h[k].Monitored { @@ -36,10 +37,17 @@ func CheckPages(h []Host) []Host { } } + if wentWrong { + u := []User{} + Db.Find(&u) + SendEmail(u, h) + } return h } func CheckAllPages(h []Host) []Host { + wentWrong := false + for k, v := range h { if resp, _, err := HttpGet(v.Url); err != nil { h[k].Status = "Error" @@ -48,6 +56,7 @@ func CheckAllPages(h []Host) []Host { h[k].Monitored = false h[k].Reason = fmt.Sprintf("%v", err) h[k].Class = "danger" + wentWrong = true } else { h[k].Status = resp.Status h[k].StatusCode = int64(resp.StatusCode) @@ -57,5 +66,10 @@ func CheckAllPages(h []Host) []Host { } } + if wentWrong { + u := []User{} + Db.Find(&u) + SendEmail(u, h) + } return h } |
