mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
small improvements (#958)
* small improvements * fix: return empty iterator if no json present * use time.Tick * changes
This commit is contained in:
@@ -102,7 +102,7 @@ func (r *AlertRule) Check(points [][]bool) (maxDuration int, passed bool) {
|
||||
hasPassedRule = true
|
||||
continue
|
||||
}
|
||||
total, fail := 0.0, 0.0
|
||||
total, fail := 0, 0
|
||||
for timeTick := len(points) - duration; timeTick < len(points); timeTick++ {
|
||||
total++
|
||||
if !points[timeTick][ruleId] {
|
||||
@@ -110,7 +110,7 @@ func (r *AlertRule) Check(points [][]bool) (maxDuration int, passed bool) {
|
||||
}
|
||||
}
|
||||
// 当70%以上的采样点未通过规则判断时 才认为当前检查未通过
|
||||
if fail/total <= 0.7 {
|
||||
if fail*100/total <= 70 {
|
||||
hasPassedRule = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func (ns *NotificationServerBundle) reqBody(message string) (string, error) {
|
||||
return string(msgBytes)[1 : len(msgBytes)-1]
|
||||
}), nil
|
||||
case NotificationRequestTypeForm:
|
||||
data, err := utils.GjsonParseStringMap(n.RequestBody)
|
||||
data, err := utils.GjsonIter(n.RequestBody)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func (n *Notification) setRequestHeader(req *http.Request) error {
|
||||
if n.RequestHeader == "" {
|
||||
return nil
|
||||
}
|
||||
m, err := utils.GjsonParseStringMap(n.RequestHeader)
|
||||
m, err := utils.GjsonIter(n.RequestHeader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user