From bb966b2c82b5341a24bb182a6a2740c6b4b5c398 Mon Sep 17 00:00:00 2001 From: naiba Date: Mon, 19 Jul 2021 20:27:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=91=20=E4=BC=98=E5=8C=96=E6=97=A0?= =?UTF-8?q?=E6=95=88=E6=95=B0=E6=8D=AE=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- cmd/dashboard/main.go | 5 ++++- model/user.go | 2 -- service/dao/dao.go | 2 +- service/dao/servicesentinel.go | 3 --- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a21be19..cad45e0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@


-    +   

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

diff --git a/cmd/dashboard/main.go b/cmd/dashboard/main.go index 12e33c6..16982f0 100644 --- a/cmd/dashboard/main.go +++ b/cmd/dashboard/main.go @@ -93,7 +93,10 @@ func recordTransferHourlyUsage() { } func cleanMonitorHistory() { - dao.DB.Unscoped().Delete(&model.MonitorHistory{}, "created_at < ?", time.Now().AddDate(0, 0, -30)) + // 清理无效数据 + dao.DB.Unscoped().Delete(&model.MonitorHistory{}, "created_at < ? OR monitor_id NOT IN (SELECT `id` FROM monitors)", time.Now().AddDate(0, 0, -30)) + dao.DB.Unscoped().Delete(&model.Transfer{}, "server_id NOT IN (SELECT `id` FROM servers)") + // 计算可清理流量记录的时长 var allServerKeep time.Time specialServerKeep := make(map[uint64]time.Time) var specialServerIDs []uint64 diff --git a/model/user.go b/model/user.go index cbd0caa..9afdcff 100644 --- a/model/user.go +++ b/model/user.go @@ -22,8 +22,6 @@ type User struct { Token string `gorm:"UNIQUE_INDEX" json:"-"` // 认证 Token TokenExpired time.Time `json:"token_expired,omitempty"` // Token 过期时间 SuperAdmin bool `json:"super_admin,omitempty"` // 超级管理员 - - TeamsID []uint64 `gorm:"-"` } func NewUserFromGitHub(gu *github.User) User { diff --git a/service/dao/dao.go b/service/dao/dao.go index a47e711..a0165f8 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.9" // !!记得修改 README 中的 badge 版本!! +var Version = "v0.9.10" // !!记得修改 README 中的 badge 版本!! var ( Conf *model.Config diff --git a/service/dao/servicesentinel.go b/service/dao/servicesentinel.go index 9554966..9131b68 100644 --- a/service/dao/servicesentinel.go +++ b/service/dao/servicesentinel.go @@ -164,9 +164,6 @@ func (ss *ServiceSentinel) OnMonitorUpdate() { var mhs []model.MonitorHistory DB.Where("created_at >= ? AND created_at < ?", today.AddDate(0, 0, -29), today).Find(&mhs) for i := 0; i < len(mhs); i++ { - if ServiceSentinelShared.monthlyStatus[mhs[i].MonitorID] == nil { - continue - } dayIndex := 28 - (int(today.Sub(mhs[i].CreatedAt).Hours()) / 24) if mhs[i].Successful { ServiceSentinelShared.monthlyStatus[mhs[i].MonitorID].TotalUp++