mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
changes
This commit is contained in:
parent
cf12f8df4d
commit
06cac05758
@ -103,14 +103,14 @@ func (r *AlertRule) Check(points [][]bool) (maxDuration int, passed bool) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
total, fail := 0, 0
|
total, fail := 0, 0
|
||||||
for _, point := range points[len(points)-duration:] {
|
for timeTick := len(points) - duration; timeTick < len(points); timeTick++ {
|
||||||
total++
|
total++
|
||||||
if !point[ruleId] {
|
if !points[timeTick][ruleId] {
|
||||||
fail++
|
fail++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 当70%以上的采样点未通过规则判断时 才认为当前检查未通过
|
// 当70%以上的采样点未通过规则判断时 才认为当前检查未通过
|
||||||
if fail*100/total*100 <= 70 {
|
if fail*100/total <= 70 {
|
||||||
hasPassedRule = true
|
hasPassedRule = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,7 @@ func AlertSentinelStart() {
|
|||||||
lastPrint := time.Now()
|
lastPrint := time.Now()
|
||||||
var checkCount uint64
|
var checkCount uint64
|
||||||
ticker := time.Tick(3 * time.Second) // 3秒钟检查一次
|
ticker := time.Tick(3 * time.Second) // 3秒钟检查一次
|
||||||
for {
|
for startedAt := range ticker {
|
||||||
startedAt := <-ticker
|
|
||||||
checkStatus()
|
checkStatus()
|
||||||
checkCount++
|
checkCount++
|
||||||
if lastPrint.Before(startedAt.Add(-1 * time.Hour)) {
|
if lastPrint.Before(startedAt.Add(-1 * time.Hour)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user