From 87ecccd58cf032bad7826c5c5ff9f1bd9c536061 Mon Sep 17 00:00:00 2001 From: naiba Date: Mon, 21 Dec 2020 22:51:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(alert):=20=E5=A4=9A=E8=A7=84?= =?UTF-8?q?=E5=88=99=E5=90=8C=E6=97=B6=E6=BB=A1=E8=B6=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/alertrule.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/model/alertrule.go b/model/alertrule.go index cc3e65c..fa6d850 100644 --- a/model/alertrule.go +++ b/model/alertrule.go @@ -91,6 +91,7 @@ func (r *AlertRule) Snapshot(server *Server) []interface{} { func (r *AlertRule) Check(points [][]interface{}) (int, string) { var dist bytes.Buffer var max int + var count int for i := 0; i < len(r.Rules); i++ { total := 0.0 fail := 0.0 @@ -108,8 +109,12 @@ func (r *AlertRule) Check(points [][]interface{}) (int, string) { } } if fail/total > 0.3 { + count++ dist.WriteString(fmt.Sprintf("%+v\n", r.Rules[i])) } } - return max, dist.String() + if count == len(r.Rules) { + return max, dist.String() + } + return max, "" }