mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
🐛 fix: 旧采样点清理及报警策略优化
This commit is contained in:
@@ -54,12 +54,15 @@ func (u *Rule) Snapshot(server *Server) interface{} {
|
||||
case "transfer_all":
|
||||
src = server.State.NetOutTransfer + server.State.NetInTransfer
|
||||
case "offline":
|
||||
src = uint64(server.LastActive.Unix())
|
||||
}
|
||||
if u.Type == "offline" {
|
||||
if uint64(time.Now().Unix())-src > 6 {
|
||||
return struct{}{}
|
||||
if server.LastActive.IsZero() {
|
||||
src = 0
|
||||
} else {
|
||||
src = uint64(server.LastActive.Unix())
|
||||
}
|
||||
}
|
||||
|
||||
if u.Type == "offline" && uint64(time.Now().Unix())-src > 6 {
|
||||
return struct{}{}
|
||||
} else if (u.Max > 0 && src > u.Max) || (u.Min > 0 && src < u.Min) {
|
||||
return struct{}{}
|
||||
}
|
||||
@@ -109,7 +112,7 @@ func (r *AlertRule) Check(points [][]interface{}) (int, string) {
|
||||
if len(points) < num {
|
||||
continue
|
||||
}
|
||||
for j := len(points) - 1; j >= 0; j-- {
|
||||
for j := len(points) - 1; j >= 0 && len(points)-num <= j; j-- {
|
||||
total++
|
||||
if points[j][i] != nil {
|
||||
fail++
|
||||
|
||||
Reference in New Issue
Block a user