Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/job/check_cpu_usage.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/web/job/check_cpu_usage.go b/web/job/check_cpu_usage.go
index 2ea87747..b2208f31 100644
--- a/web/job/check_cpu_usage.go
+++ b/web/job/check_cpu_usage.go
@@ -22,7 +22,11 @@ func NewCheckCpuJob() *CheckCpuJob {
// Run checks CPU usage over the last minute and sends a Telegram alert if it exceeds the threshold.
func (j *CheckCpuJob) Run() {
- threshold, _ := j.settingService.GetTgCpu()
+ threshold, err := j.settingService.GetTgCpu()
+ if err != nil || threshold <= 0 {
+ // If threshold cannot be retrieved or is not set, skip sending notifications
+ return
+ }
// get latest status of server
percent, err := cpu.Percent(1*time.Minute, false)