This repository has been archived on 2019-06-27. You can view files and clone it, but cannot push or open issues/pull-requests.
am/background.go

35 lines
561 B
Go

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)
runAlertAction(src.Name, e.Text)
_ = db.SourceUpdateAlertedAt(src.SourceID)
}
}
}
func purgeOldEntries() {
for {
_ = db.LogDeleteBefore(time.Now().Add(-90 * 24 * time.Hour))
time.Sleep(10 * time.Minute)
}
}