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
path: root/web/job
diff options
context:
space:
mode:
authorHo3ein <ho3ein.sanaei@gmail.com>2023-05-22 10:56:14 +0300
committerGitHub <noreply@github.com>2023-05-22 10:56:14 +0300
commit5f489c3d08b36c9569fa67f0c5bf46be8ada7b21 (patch)
tree0241a998df1f52f5170aec9bc263414e8a2a3e96 /web/job
parent3d712890753a4f9981cca95685dec7ad4fff0acf (diff)
parentf82d0051b2cf827228b5c939d22622bd0d066149 (diff)
Merge pull request #491 from hamid-gh98/main
[tgbot] Multi language + More...
Diffstat (limited to 'web/job')
-rw-r--r--web/job/check_cpu_usage.go7
-rw-r--r--web/job/check_hash_storage.go19
2 files changed, 24 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)
}
}
diff --git a/web/job/check_hash_storage.go b/web/job/check_hash_storage.go
new file mode 100644
index 00000000..468aa2e0
--- /dev/null
+++ b/web/job/check_hash_storage.go
@@ -0,0 +1,19 @@
+package job
+
+import (
+ "x-ui/web/service"
+)
+
+type CheckHashStorageJob struct {
+ tgbotService service.Tgbot
+}
+
+func NewCheckHashStorageJob() *CheckHashStorageJob {
+ return new(CheckHashStorageJob)
+}
+
+// Here Run is an interface method of the Job interface
+func (j *CheckHashStorageJob) Run() {
+ // Remove expired hashes from storage
+ j.tgbotService.GetHashStorage().RemoveExpiredHashes()
+}