Commit 87d85f7e authored by jingbo.wang's avatar jingbo.wang

node check 调优

parent 5cc989d3
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/vrg0/go-common/registry" "github.com/vrg0/go-common/registry"
"strings" "strings"
"sync" "sync"
"time"
) )
var ( var (
...@@ -116,11 +117,22 @@ func (w watch) statusCheckAndNotify(service *registry.Service) { ...@@ -116,11 +117,22 @@ func (w watch) statusCheckAndNotify(service *registry.Service) {
if oldService, ok := w.serviceMap[node.ServiceName]; ok { if oldService, ok := w.serviceMap[node.ServiceName]; ok {
if oldNode, ok := oldService.NodeMap[node.Id]; ok { if oldNode, ok := oldService.NodeMap[node.Id]; ok {
if oldNode.Status == registry.Passing && node.Status != registry.Passing { if oldNode.Status == registry.Passing && node.Status != registry.Passing {
s := fmt.Sprintf("服务节点健康状态异常:%s %s:%s", service.Name, node.Id, node.Status) go DelayedAlarm(node)
}
}
}
}
}
func DelayedAlarm(node *registry.Node) {
time.Sleep(time.Second * 6)
if nowService, ok := registry.GetService(node.ServiceName); ok {
if nowNode, ok := nowService.NodeMap[node.Id]; ok {
if nowNode.Status == registry.Critical {
s := fmt.Sprintf("服务节点健康状态异常:%s %s:%s", node.ServiceName, node.Id, node.Status)
glog.Warn(s) glog.Warn(s)
notifyDingDing.SendText(s) notifyDingDing.SendText(s)
} }
} }
} }
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment