diff options
| author | Hamidreza Ghavami <70919649+hamid-gh98@users.noreply.github.com> | 2023-05-21 02:00:26 +0300 |
|---|---|---|
| committer | Hamidreza Ghavami <70919649+hamid-gh98@users.noreply.github.com> | 2023-05-21 02:00:26 +0300 |
| commit | 82ead0509359aa364cc188ef7f22e74cd45fe347 (patch) | |
| tree | b63dea73097dbf0785d110981478d005c8fd00b8 /web/job | |
| parent | d9b1b200cebb82087037d505f13151dd425577a6 (diff) | |
Update tgbot locale + add I18nBot
Diffstat (limited to 'web/job')
| -rw-r--r-- | web/job/check_cpu_usage.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/web/job/check_cpu_usage.go b/web/job/check_cpu_usage.go index cfc86b60..74f6a544 100644 --- a/web/job/check_cpu_usage.go +++ b/web/job/check_cpu_usage.go @@ -1,7 +1,7 @@ package job import ( - "fmt" + "strconv" "time" "x-ui/web/service" @@ -24,7 +24,10 @@ func (j *CheckCpuJob) Run() { // get latest status of server percent, err := cpu.Percent(1*time.Second, false) if err == nil && percent[0] > float64(threshold) { - msg := fmt.Sprintf("🔴 CPU usage %.2f%% is more than threshold %d%%", percent[0], threshold) + msg := j.tgbotService.I18nBot("tgbot.messages.cpuThreshold", + "Percent=="+strconv.FormatFloat(percent[0], 'f', 2, 64), + "Threshold=="+strconv.Itoa(threshold)) + j.tgbotService.SendMsgToTgbotAdmins(msg) } } |
