feat(memory): add memory threshold alerts (#5366)

* feat(memory): add memory threshold alerts

Add memory (RAM) threshold alerts following the same architecture as
CPU alerts: CheckMemJob with @every 1m cadence, memoryAlarmWanted gate,
tgMemory/smtpMemory per-subscriber settings (default 80%), EventBusCheckboxes
with inline threshold input, i18n for en-US/ru-RU with English defaults.

# Conflicts:
#	internal/web/translation/ar-EG.json
#	internal/web/translation/es-ES.json
#	internal/web/translation/fa-IR.json
#	internal/web/translation/id-ID.json
#	internal/web/translation/ja-JP.json
#	internal/web/translation/pt-BR.json
#	internal/web/translation/ru-RU.json
#	internal/web/translation/tr-TR.json
#	internal/web/translation/uk-UA.json
#	internal/web/translation/vi-VN.json
#	internal/web/translation/zh-CN.json
#	internal/web/translation/zh-TW.json

* fix: address code review findings for memory alerts

- Remove dead settingService field from CheckMemJob
- Fix cpuThreshold double-emoji in 12 locale files (code prepends 🔴)
- Align TgCpu/TgMemory fields in entity.go
- Add missing SetTgMemory function

* fix: restore settingService in CheckMemJob for consistency with CheckCpuJob
This commit is contained in:
Sentiago
2026-06-21 18:45:33 +03:00
committed by GitHub
parent 648fc69cb1
commit 891d3a8759
28 changed files with 267 additions and 39 deletions
+4
View File
@@ -35,6 +35,7 @@ export const EXAMPLES: Record<string, unknown> = {
"smtpEnabledEvents": "",
"smtpEncryptionType": "",
"smtpHost": "",
"smtpMemory": 0,
"smtpPassword": "",
"smtpPort": 1,
"smtpTo": "",
@@ -77,6 +78,7 @@ export const EXAMPLES: Record<string, unknown> = {
"tgCpu": 0,
"tgEnabledEvents": "",
"tgLang": "",
"tgMemory": 0,
"tgRunTime": "",
"timeLocation": "",
"trafficDiff": 0,
@@ -133,6 +135,7 @@ export const EXAMPLES: Record<string, unknown> = {
"smtpEnabledEvents": "",
"smtpEncryptionType": "",
"smtpHost": "",
"smtpMemory": 0,
"smtpPassword": "",
"smtpPort": 1,
"smtpTo": "",
@@ -175,6 +178,7 @@ export const EXAMPLES: Record<string, unknown> = {
"tgCpu": 0,
"tgEnabledEvents": "",
"tgLang": "",
"tgMemory": 0,
"tgRunTime": "",
"timeLocation": "",
"trafficDiff": 0,
+28
View File
@@ -134,6 +134,12 @@ export const SCHEMAS: Record<string, unknown> = {
"description": "SMTP server host",
"type": "string"
},
"smtpMemory": {
"description": "Memory threshold for email notifications",
"maximum": 100,
"minimum": 0,
"type": "integer"
},
"smtpPassword": {
"description": "SMTP password",
"type": "string"
@@ -309,6 +315,12 @@ export const SCHEMAS: Record<string, unknown> = {
"description": "Telegram bot language",
"type": "string"
},
"tgMemory": {
"description": "Memory usage threshold for alerts (percent)",
"maximum": 100,
"minimum": 0,
"type": "integer"
},
"tgRunTime": {
"description": "Cron schedule for Telegram notifications",
"type": "string"
@@ -402,6 +414,7 @@ export const SCHEMAS: Record<string, unknown> = {
"smtpEnabledEvents",
"smtpEncryptionType",
"smtpHost",
"smtpMemory",
"smtpPassword",
"smtpPort",
"smtpTo",
@@ -444,6 +457,7 @@ export const SCHEMAS: Record<string, unknown> = {
"tgCpu",
"tgEnabledEvents",
"tgLang",
"tgMemory",
"tgRunTime",
"timeLocation",
"trafficDiff",
@@ -615,6 +629,12 @@ export const SCHEMAS: Record<string, unknown> = {
"description": "SMTP server host",
"type": "string"
},
"smtpMemory": {
"description": "Memory threshold for email notifications",
"maximum": 100,
"minimum": 0,
"type": "integer"
},
"smtpPassword": {
"description": "SMTP password",
"type": "string"
@@ -790,6 +810,12 @@ export const SCHEMAS: Record<string, unknown> = {
"description": "Telegram bot language",
"type": "string"
},
"tgMemory": {
"description": "Memory usage threshold for alerts (percent)",
"maximum": 100,
"minimum": 0,
"type": "integer"
},
"tgRunTime": {
"description": "Cron schedule for Telegram notifications",
"type": "string"
@@ -890,6 +916,7 @@ export const SCHEMAS: Record<string, unknown> = {
"smtpEnabledEvents",
"smtpEncryptionType",
"smtpHost",
"smtpMemory",
"smtpPassword",
"smtpPort",
"smtpTo",
@@ -932,6 +959,7 @@ export const SCHEMAS: Record<string, unknown> = {
"tgCpu",
"tgEnabledEvents",
"tgLang",
"tgMemory",
"tgRunTime",
"timeLocation",
"trafficDiff",
+4
View File
@@ -41,6 +41,7 @@ export interface AllSetting {
smtpEnabledEvents: string;
smtpEncryptionType: string;
smtpHost: string;
smtpMemory: number;
smtpPassword: string;
smtpPort: number;
smtpTo: string;
@@ -83,6 +84,7 @@ export interface AllSetting {
tgCpu: number;
tgEnabledEvents: string;
tgLang: string;
tgMemory: number;
tgRunTime: string;
timeLocation: string;
trafficDiff: number;
@@ -140,6 +142,7 @@ export interface AllSettingView {
smtpEnabledEvents: string;
smtpEncryptionType: string;
smtpHost: string;
smtpMemory: number;
smtpPassword: string;
smtpPort: number;
smtpTo: string;
@@ -182,6 +185,7 @@ export interface AllSettingView {
tgCpu: number;
tgEnabledEvents: string;
tgLang: string;
tgMemory: number;
tgRunTime: string;
timeLocation: string;
trafficDiff: number;
+4
View File
@@ -53,6 +53,7 @@ export const AllSettingSchema = z.object({
smtpEnabledEvents: z.string(),
smtpEncryptionType: z.string(),
smtpHost: z.string(),
smtpMemory: z.number().int().min(0).max(100),
smtpPassword: z.string(),
smtpPort: z.number().int().min(1).max(65535),
smtpTo: z.string(),
@@ -95,6 +96,7 @@ export const AllSettingSchema = z.object({
tgCpu: z.number().int().min(0).max(100),
tgEnabledEvents: z.string(),
tgLang: z.string(),
tgMemory: z.number().int().min(0).max(100),
tgRunTime: z.string(),
timeLocation: z.string(),
trafficDiff: z.number().int().min(0).max(100),
@@ -153,6 +155,7 @@ export const AllSettingViewSchema = z.object({
smtpEnabledEvents: z.string(),
smtpEncryptionType: z.string(),
smtpHost: z.string(),
smtpMemory: z.number().int().min(0).max(100),
smtpPassword: z.string(),
smtpPort: z.number().int().min(1).max(65535),
smtpTo: z.string(),
@@ -195,6 +198,7 @@ export const AllSettingViewSchema = z.object({
tgCpu: z.number().int().min(0).max(100),
tgEnabledEvents: z.string(),
tgLang: z.string(),
tgMemory: z.number().int().min(0).max(100),
tgRunTime: z.string(),
timeLocation: z.string(),
trafficDiff: z.number().int().min(0).max(100),