Add CPU load alarm #34

This commit is contained in:
Alireza Ahmadi
2023-03-10 14:11:31 +01:00
parent 546b66a61c
commit e1c76fdc7a
4 changed files with 40 additions and 4 deletions

View File

@@ -325,6 +325,13 @@ func (s *Server) startTask() {
logger.Warning("Add NewStatsNotifyJob error", err)
return
}
// Check CPU load and alarm to TgBot if threshold passes
cpuThreshold, err := s.settingService.GetTgCpu()
if (err == nil) && (cpuThreshold > 0) {
s.cron.AddJob("@every 10s", job.NewCheckCpuJob())
}
} else {
s.cron.Remove(entry)
}