🔊 dashboard: 默认输出服务故障上报日志

This commit is contained in:
naiba
2021-08-27 21:04:37 +08:00
parent ff15dfbbb8
commit d7ea114068
6 changed files with 17 additions and 24 deletions

View File

@@ -13,7 +13,7 @@ import (
pb "github.com/naiba/nezha/proto"
)
var Version = "v0.9.30" // !!记得修改 README 中的 badge 版本!!
var Version = "v0.9.31" // !!记得修改 README 中的 badge 版本!!
var (
Conf *model.Config

View File

@@ -71,7 +71,7 @@ func SendNotification(desc string, muteable bool) {
if !flag {
if Conf.Debug {
log.Println("muted notification", desc, muteable)
log.Println("静音的重复通知:", desc, muteable)
}
return
}
@@ -80,6 +80,8 @@ func SendNotification(desc string, muteable bool) {
notificationsLock.RLock()
defer notificationsLock.RUnlock()
for i := 0; i < len(notifications); i++ {
notifications[i].Send(desc)
if err := notifications[i].Send(desc); err != nil {
log.Println("发送通知失败:", err)
}
}
}

View File

@@ -269,7 +269,7 @@ func (ss *ServiceSentinel) worker() {
ss.serviceCurrentStatusIndex[mh.MonitorID] = 0
dataToSave := ss.serviceCurrentStatusData[mh.MonitorID]
if err := DB.Create(&dataToSave).Error; err != nil {
log.Println(err)
log.Println("服务监控数据持久化失败:", err)
}
}
// 更新当前状态
@@ -289,9 +289,9 @@ func (ss *ServiceSentinel) worker() {
upPercent = ss.serviceResponseDataStoreCurrentUp[mh.MonitorID] * 100 / (ss.serviceResponseDataStoreCurrentDown[mh.MonitorID] + ss.serviceResponseDataStoreCurrentUp[mh.MonitorID])
}
stateStr := getStateStr(upPercent)
if Conf.Debug {
if !mh.Successful {
ServerLock.RLock()
log.Println("服务监控上报:", ss.monitors[mh.MonitorID].Target, stateStr, "上报者:", ServerList[r.Reporter].Name, "是否正常:", mh.Successful, "请求输出:", mh.Data)
log.Println("服务故障上报", ss.monitors[mh.MonitorID].Target, stateStr, "上报者", ServerList[r.Reporter].Name, "请求输出", mh.Data)
ServerLock.RUnlock()
}
if stateStr == "故障" || stateStr != ss.lastStatus[mh.MonitorID] {