diff --git a/README.md b/README.md
index 3ad6733ab6..462f97b8cc 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
LOGO designed by 熊大 .
-
+
:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。
diff --git a/cmd/agent/main.go b/cmd/agent/main.go index c57b7bdb03..9989b8e047 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -120,7 +120,7 @@ func run() { timeOutCtx, cancel := context.WithTimeout(context.Background(), networkTimeOut) conn, err = grpc.DialContext(timeOutCtx, server, grpc.WithInsecure(), grpc.WithPerRPCCredentials(&auth)) if err != nil { - println("grpc.Dial err: ", err) + println("与面板建立连接失败:", err) cancel() retry() continue @@ -131,7 +131,7 @@ func run() { timeOutCtx, cancel = context.WithTimeout(context.Background(), networkTimeOut) _, err = client.ReportSystemInfo(timeOutCtx, monitor.GetHost().PB()) if err != nil { - println("client.ReportSystemInfo err: ", err) + println("上报系统信息失败:", err) cancel() retry() continue @@ -141,12 +141,12 @@ func run() { // 执行 Task tasks, err := client.RequestTask(context.Background(), monitor.GetHost().PB()) if err != nil { - println("client.RequestTask err: ", err) + println("请求任务失败:", err) retry() continue } err = receiveTasks(tasks) - println("receiveTasks exit to main: ", err) + println("receiveTasks exit to main:", err) retry() } } @@ -187,7 +187,7 @@ func doTask(task *pb.Task) { case model.TaskTypeCommand: handleCommandTask(task, &result) default: - println("Unknown action: ", task) + println("不支持的任务:", task) } client.ReportTask(context.Background(), &result) } @@ -222,16 +222,13 @@ func doSelfUpdate() { updateCh <- struct{}{} }() v := semver.MustParse(version) - println("Check update", v) + println("检查更新:", v) latest, err := selfupdate.UpdateSelf(v, "naiba/nezha") if err != nil { - println("Binary update failed:", err) + println("自动更新失败:", err) return } - if latest.Version.Equals(v) { - println("Current binary is up to date", version) - } else { - println("Upgrade successfully", latest.Version) + if !latest.Version.Equals(v) { os.Exit(1) } } diff --git a/model/notification.go b/model/notification.go index 0d1b0c462a..81ebf9b2e4 100644 --- a/model/notification.go +++ b/model/notification.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "log" "net/http" "net/url" "strings" @@ -102,11 +101,6 @@ func (n *Notification) Send(message string) error { err = fmt.Errorf("%d %s", resp.StatusCode, resp.Status) } - // defer resp.Body.Close() - // body, _ := ioutil.ReadAll(resp.Body) - - log.Printf("%s 通知:%s %s %+v\n", n.Name, message, reqBody, err) - return err } diff --git a/service/dao/dao.go b/service/dao/dao.go index 367fe8cdd1..31280802f8 100644 --- a/service/dao/dao.go +++ b/service/dao/dao.go @@ -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 diff --git a/service/dao/notification.go b/service/dao/notification.go index aa348d8df6..30da3179e0 100644 --- a/service/dao/notification.go +++ b/service/dao/notification.go @@ -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) + } } } diff --git a/service/dao/servicesentinel.go b/service/dao/servicesentinel.go index c82920f1c2..d3bf29e8cf 100644 --- a/service/dao/servicesentinel.go +++ b/service/dao/servicesentinel.go @@ -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] {