Allow critical-only load alerts
This commit is contained in:
@@ -24,6 +24,7 @@ This project uses `config.yaml`. Start from `config.example.yaml`.
|
|||||||
- `interval_sec` (int): Poll interval.
|
- `interval_sec` (int): Poll interval.
|
||||||
- `cooldown_sec` (int): Cooldown between alerts.
|
- `cooldown_sec` (int): Cooldown between alerts.
|
||||||
- `notify_cooldown_sec` (int): Global alert dedup cooldown (defaults to `cooldown_sec`).
|
- `notify_cooldown_sec` (int): Global alert dedup cooldown (defaults to `cooldown_sec`).
|
||||||
|
- `load_only_critical` (bool): Only send critical load alerts (no warn/OK).
|
||||||
- `quiet_hours` (object): Quiet hours for non‑critical alerts.
|
- `quiet_hours` (object): Quiet hours for non‑critical alerts.
|
||||||
- `enabled` (bool): Enable quiet hours.
|
- `enabled` (bool): Enable quiet hours.
|
||||||
- `start` (string): Start time `HH:MM` (e.g. `23:00`).
|
- `start` (string): Start time `HH:MM` (e.g. `23:00`).
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
- `interval_sec` (int): интервал опроса.
|
- `interval_sec` (int): интервал опроса.
|
||||||
- `cooldown_sec` (int): кулдаун между алертами.
|
- `cooldown_sec` (int): кулдаун между алертами.
|
||||||
- `notify_cooldown_sec` (int): глобальный дедуп алертов (по умолчанию `cooldown_sec`).
|
- `notify_cooldown_sec` (int): глобальный дедуп алертов (по умолчанию `cooldown_sec`).
|
||||||
|
- `load_only_critical` (bool): слать только критичные алерты по нагрузке (без warn/OK).
|
||||||
- `quiet_hours` (object): тихие часы для не‑критичных уведомлений.
|
- `quiet_hours` (object): тихие часы для не‑критичных уведомлений.
|
||||||
- `enabled` (bool): включить тихие часы.
|
- `enabled` (bool): включить тихие часы.
|
||||||
- `start` (string): начало, формат `HH:MM` (например `23:00`).
|
- `start` (string): начало, формат `HH:MM` (например `23:00`).
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ alerts:
|
|||||||
cooldown_sec: 900
|
cooldown_sec: 900
|
||||||
# Optional global dedup cooldown for notify() calls
|
# Optional global dedup cooldown for notify() calls
|
||||||
notify_cooldown_sec: 900
|
notify_cooldown_sec: 900
|
||||||
|
# If true, only critical load alerts are sent (no warn/OK)
|
||||||
|
load_only_critical: false
|
||||||
quiet_hours:
|
quiet_hours:
|
||||||
enabled: false
|
enabled: false
|
||||||
start: "23:00"
|
start: "23:00"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ async def monitor_resources(cfg, notify, bot, chat_id):
|
|||||||
interval = int(alerts_cfg.get("interval_sec", 60))
|
interval = int(alerts_cfg.get("interval_sec", 60))
|
||||||
cooldown = int(alerts_cfg.get("cooldown_sec", 900))
|
cooldown = int(alerts_cfg.get("cooldown_sec", 900))
|
||||||
notify_recovery = bool(alerts_cfg.get("notify_recovery", True))
|
notify_recovery = bool(alerts_cfg.get("notify_recovery", True))
|
||||||
|
load_only_critical = bool(alerts_cfg.get("load_only_critical", False))
|
||||||
|
|
||||||
disk_warn = int(cfg.get("thresholds", {}).get("disk_warn", 80))
|
disk_warn = int(cfg.get("thresholds", {}).get("disk_warn", 80))
|
||||||
snapshot_warn = int(cfg.get("disk_report", {}).get("threshold", disk_warn))
|
snapshot_warn = int(cfg.get("disk_report", {}).get("threshold", disk_warn))
|
||||||
@@ -57,9 +58,11 @@ async def monitor_resources(cfg, notify, bot, chat_id):
|
|||||||
level = 1
|
level = 1
|
||||||
else:
|
else:
|
||||||
level = 0
|
level = 0
|
||||||
|
if load_only_critical and level == 1:
|
||||||
|
level = 0
|
||||||
|
|
||||||
if level == 0:
|
if level == 0:
|
||||||
if state["load_level"] > 0 and notify_recovery:
|
if state["load_level"] > 0 and notify_recovery and not load_only_critical:
|
||||||
await notify(bot, chat_id, f"🟢 Load OK: {load:.2f}", level="info", key="load_ok")
|
await notify(bot, chat_id, f"🟢 Load OK: {load:.2f}", level="info", key="load_ok")
|
||||||
state["load_level"] = 0
|
state["load_level"] = 0
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user