mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-14 02:12:42 +00:00
fix: handle CPU threshold error to prevent false notifications (#3603)
Some checks failed
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled
Release 3X-UI / Build for Windows (push) Has been cancelled
Some checks failed
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled
Release 3X-UI / Build for Windows (push) Has been cancelled
Previously, when GetTgCpu() failed, the error was ignored and threshold defaulted to 0, causing notifications to be sent for any CPU usage. Now the job properly checks for errors and skips notifications if: - The threshold cannot be retrieved (error) - The threshold is not set or is 0 This ensures notifications are only sent when CPU usage exceeds the configured threshold value from settings.
This commit is contained in:
parent
0ea8b5352a
commit
f000322a06
1 changed files with 5 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue