diff --git a/README.md b/README.md index f821c2d..02d67d5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@
LOGO designed by 熊大 .

-    +   

:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。

diff --git a/cmd/dashboard/controller/member_api.go b/cmd/dashboard/controller/member_api.go index 9c9b3bd..a195237 100644 --- a/cmd/dashboard/controller/member_api.go +++ b/cmd/dashboard/controller/member_api.go @@ -457,7 +457,6 @@ type settingForm struct { ViewPassword string EnableIPChangeNotification string IgnoredIPNotification string - Oauth2Type string GRPCHost string Cover uint8 } @@ -479,7 +478,6 @@ func (ma *memberAPI) updateSetting(c *gin.Context) { dao.Conf.Site.Theme = sf.Theme dao.Conf.Site.CustomCode = sf.CustomCode dao.Conf.Site.ViewPassword = sf.ViewPassword - dao.Conf.Oauth2.Type = sf.Oauth2Type dao.Conf.Oauth2.Admin = sf.Admin if err := dao.Conf.Save(); err != nil { c.JSON(http.StatusOK, model.Response{ diff --git a/cmd/dashboard/main.go b/cmd/dashboard/main.go index 1f1d030..fe6cb58 100644 --- a/cmd/dashboard/main.go +++ b/cmd/dashboard/main.go @@ -1,7 +1,9 @@ package main import ( + "bytes" "context" + "fmt" "log" "time" @@ -56,6 +58,7 @@ func initSystem() { model.Notification{}, model.AlertRule{}, model.Monitor{}, model.MonitorHistory{}, model.Cron{}, model.Transfer{}) + dao.LoadNotifications() loadServers() //加载服务器列表 loadCrons() //加载计划任务 @@ -153,6 +156,7 @@ func loadCrons() { var crons []model.Cron dao.DB.Find(&crons) var err error + errMsg := new(bytes.Buffer) for i := 0; i < len(crons); i++ { cr := crons[i] @@ -165,9 +169,16 @@ func loadCrons() { if err == nil { dao.Crons[cr.ID] = &cr } else { - log.Println("NEZHA>> 计划任务调度失败", cr, err) + if errMsg.Len() == 0 { + errMsg.WriteString("调度失败的计划任务:[") + } + errMsg.WriteString(fmt.Sprintf("%d,", cr.ID)) } } + if errMsg.Len() > 0 { + msg := errMsg.String() + dao.SendNotification(msg[:len(msg)-1]+"] 这些任务将无法正常执行,请进入后点重新修改保存。", false) + } dao.Cron.Start() } diff --git a/resource/template/dashboard/setting.html b/resource/template/dashboard/setting.html index 4846f68..aaf1b7b 100644 --- a/resource/template/dashboard/setting.html +++ b/resource/template/dashboard/setting.html @@ -8,15 +8,6 @@ -
- - -
diff --git a/service/dao/alertsentinel.go b/service/dao/alertsentinel.go index cc87992..5e22113 100644 --- a/service/dao/alertsentinel.go +++ b/service/dao/alertsentinel.go @@ -30,11 +30,6 @@ type NotificationHistory struct { func AlertSentinelStart() { alertsStore = make(map[uint64]map[uint64][][]interface{}) alertsPrevState = make(map[uint64]map[uint64]uint) - notificationsLock.Lock() - if err := DB.Find(¬ifications).Error; err != nil { - panic(err) - } - notificationsLock.Unlock() alertsLock.Lock() if err := DB.Find(&alerts).Error; err != nil { panic(err) diff --git a/service/dao/dao.go b/service/dao/dao.go index b8d8a0c..e00704f 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.10.2" // !!记得修改 README 中的 badge 版本!! +var Version = "v0.10.3" // !!记得修改 README 中的 badge 版本!! var ( Conf *model.Config diff --git a/service/dao/notification.go b/service/dao/notification.go index bc675de..b5736e5 100644 --- a/service/dao/notification.go +++ b/service/dao/notification.go @@ -16,6 +16,14 @@ const firstNotificationDelay = time.Minute * 15 var notifications []model.Notification var notificationsLock sync.RWMutex +func LoadNotifications() { + notificationsLock.Lock() + if err := DB.Find(¬ifications).Error; err != nil { + panic(err) + } + notificationsLock.Unlock() +} + func OnRefreshOrAddNotification(n model.Notification) { notificationsLock.Lock() defer notificationsLock.Unlock() diff --git a/service/dao/servicesentinel.go b/service/dao/servicesentinel.go index 0cce017..833a3dc 100644 --- a/service/dao/servicesentinel.go +++ b/service/dao/servicesentinel.go @@ -146,7 +146,6 @@ func (ss *ServiceSentinel) loadMonitorHistory() { monitors[i].CronJobID, err = Cron.AddFunc(task.CronSpec(), func() { ss.dispatchBus <- task }) - log.Println("NEZHA>> 服务监控任务", monitors[i].ID, monitors[i].Name, monitors[i].CronJobID) if err != nil { panic(err) }