diff options
| author | Horus3 | 2015-02-27 04:02:15 +0100 |
|---|---|---|
| committer | Horus3 | 2015-02-27 04:02:15 +0100 |
| commit | 6837ddf68f13a1633ea868ab55d71389ca5bc175 (patch) | |
| tree | 94fbfabdfa4506eb1b2dbf0067a7c0fa87f294c9 /app/fetch.go | |
| parent | 60767a3ea8190d3f070f3aae86c2d72ffb10cfd6 (diff) | |
| download | statuspage-6837ddf68f13a1633ea868ab55d71389ca5bc175.tar.gz | |
Version 0.2. Sends E-Mails now. Also sticky post on index page to quickly inform people. Concatenated all CSS and JavaScript files.
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 } |
