small improvements (#958)

* small improvements

* fix: return empty iterator if no json present

* use time.Tick

* changes
This commit is contained in:
UUBulb
2025-01-19 21:22:00 +08:00
committed by GitHub
parent 844865e2c1
commit 4b1af369e3
10 changed files with 34 additions and 34 deletions

View File

@@ -74,20 +74,19 @@ func AlertSentinelStart() {
AlertsLock.Unlock()
time.Sleep(time.Second * 10)
var lastPrint time.Time
lastPrint := time.Now()
var checkCount uint64
for {
startedAt := time.Now()
ticker := time.Tick(3 * time.Second) // 3秒钟检查一次
for startedAt := range ticker {
checkStatus()
checkCount++
if lastPrint.Before(startedAt.Add(-1 * time.Hour)) {
if Conf.Debug {
log.Println("NEZHA>> 报警规则检测每小时", checkCount, "次", startedAt, time.Now())
log.Printf("NEZHA>> Checking alert rules %d times each hour %v %v", checkCount, startedAt, time.Now())
}
checkCount = 0
lastPrint = startedAt
}
time.Sleep(time.Until(startedAt.Add(time.Second * 3))) // 3秒钟检查一次
}
}