fix: 修改监控默认采集间隔和保存时间 (#1795)

pull/1797/head
ssongliu 2023-07-31 22:06:37 +08:00 committed by GitHub
parent b59ccc52ae
commit e0ca9507de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -167,10 +167,12 @@ func StartMonitor(removeBefore bool, interval string) error {
if removeBefore {
global.Cron.Remove(cron.EntryID(global.MonitorCronID))
}
monitorID, err := global.Cron.AddJob(fmt.Sprintf("@every %sm", interval), NewIMonitorService())
imservice := NewIMonitorService()
monitorID, err := global.Cron.AddJob(fmt.Sprintf("@every %sm", interval), imservice)
if err != nil {
return err
}
imservice.Run()
global.MonitorCronID = int(monitorID)
return nil
}

View File

@ -127,7 +127,7 @@ var AddTableSetting = &gormigrate.Migration{
if err := tx.Create(&model.Setting{Key: "MonitorStatus", Value: "enable"}).Error; err != nil {
return err
}
if err := tx.Create(&model.Setting{Key: "MonitorStoreDays", Value: "30"}).Error; err != nil {
if err := tx.Create(&model.Setting{Key: "MonitorStoreDays", Value: "7"}).Error; err != nil {
return err
}
@ -354,7 +354,7 @@ var AddBindAndAllowIPs = &gormigrate.Migration{
if err := tx.Create(&model.Setting{Key: "NtpSite", Value: "pool.ntp.org"}).Error; err != nil {
return err
}
if err := tx.Create(&model.Setting{Key: "MonitorInterval", Value: "1"}).Error; err != nil {
if err := tx.Create(&model.Setting{Key: "MonitorInterval", Value: "5"}).Error; err != nil {
return err
}
return nil