mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 20:50:06 +00:00
通知内 IP 脱敏
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/naiba/nezha/model"
|
||||
"github.com/naiba/nezha/pkg/utils"
|
||||
)
|
||||
|
||||
// 报警规则
|
||||
@@ -100,7 +101,7 @@ func checkStatus() {
|
||||
// 发送通知
|
||||
max, desc := alert.Check(alertsStore[alert.ID][server.ID])
|
||||
if desc != "" {
|
||||
message := fmt.Sprintf("报警规则:%s,服务器:%s(%s),%s,逮到咯,快去看看!", alert.Name, server.Name, server.Host.IP, desc)
|
||||
message := fmt.Sprintf("报警规则:%s,服务器:%s(%s),逮到咯,快去看看!", alert.Name, server.Name, utils.IPDesensitize(server.Host.IP))
|
||||
go SendNotification(message, true)
|
||||
}
|
||||
// 清理旧数据
|
||||
|
||||
@@ -69,7 +69,7 @@ func CronTrigger(c *model.Cron) {
|
||||
Type: model.TaskTypeCommand,
|
||||
})
|
||||
} else {
|
||||
SendNotification(fmt.Sprintf("计划任务:%s,服务器:%d 离线,无法执行。", c.Name, c.Servers[j]), false)
|
||||
SendNotification(fmt.Sprintf("计划任务:%s,服务器:%s 离线,无法执行。", c.Name, ServerList[c.Servers[j]].Name), false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,9 @@ func (ss *ServiceSentinel) worker() {
|
||||
}
|
||||
stateStr := getStateStr(upPercent)
|
||||
if Conf.Debug {
|
||||
log.Println("服务监控上报:", ss.monitors[mh.MonitorID].Target, stateStr, "上报者:", r.Reporter, "是否正常:", mh.Successful, "请求输出:", mh.Data)
|
||||
ServerLock.RLock()
|
||||
log.Println("服务监控上报:", ss.monitors[mh.MonitorID].Target, stateStr, "上报者:", ServerList[r.Reporter].Name, "是否正常:", mh.Successful, "请求输出:", mh.Data)
|
||||
ServerLock.RUnlock()
|
||||
}
|
||||
if stateStr == "故障" || stateStr != ss.lastStatus[mh.MonitorID] {
|
||||
ss.monitorsLock.RLock()
|
||||
|
||||
@@ -31,11 +31,13 @@ func (s *NezhaHandler) ReportTask(c context.Context, r *pb.TaskResult) (*pb.Rece
|
||||
defer dao.CronLock.RUnlock()
|
||||
cr := dao.Crons[r.GetId()]
|
||||
if cr != nil {
|
||||
dao.ServerLock.RLock()
|
||||
defer dao.ServerLock.RUnlock()
|
||||
if cr.PushSuccessful && r.GetSuccessful() {
|
||||
dao.SendNotification(fmt.Sprintf("成功计划任务:%s ,服务器:%d,日志:\n%s", cr.Name, clientID, r.GetData()), false)
|
||||
dao.SendNotification(fmt.Sprintf("成功计划任务:%s ,服务器:%s,日志:\n%s", cr.Name, dao.ServerList[clientID].Name, r.GetData()), false)
|
||||
}
|
||||
if !r.GetSuccessful() {
|
||||
dao.SendNotification(fmt.Sprintf("失败计划任务:%s ,服务器:%d,日志:\n%s", cr.Name, clientID, r.GetData()), false)
|
||||
dao.SendNotification(fmt.Sprintf("失败计划任务:%s ,服务器:%s,日志:\n%s", cr.Name, dao.ServerList[clientID].Name, r.GetData()), false)
|
||||
}
|
||||
dao.DB.Model(cr).Updates(model.Cron{
|
||||
LastExecutedAt: time.Now().Add(time.Second * -1 * time.Duration(r.GetDelay())),
|
||||
|
||||
Reference in New Issue
Block a user