This repository has been archived on 2019-06-27. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-06-10 17:09:10 +00:00
|
|
|
package am
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
func processTimeouts() {
|
|
|
|
for {
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
|
|
|
|
l, _ := db.SourceList()
|
|
|
|
|
|
|
|
for _, src := range l {
|
|
|
|
if !src.RequiresAlertForTimeout() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
e := Entry{
|
|
|
|
SourceID: src.SourceID,
|
|
|
|
Alert: true,
|
|
|
|
Text: "Source hasn't reported in.",
|
|
|
|
}
|
|
|
|
|
|
|
|
_ = db.LogInsert(e)
|
2019-06-11 07:44:35 +00:00
|
|
|
runAlertAction(src.Name, e.Text)
|
2019-06-10 17:09:10 +00:00
|
|
|
_ = db.SourceUpdateAlertedAt(src.SourceID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func purgeOldEntries() {
|
|
|
|
for {
|
|
|
|
_ = db.LogDeleteBefore(time.Now().Add(-90 * 24 * time.Hour))
|
|
|
|
time.Sleep(10 * time.Minute)
|
|
|
|
}
|
|
|
|
}
|