1.3 KiB
1.3 KiB
子机离线 Telegram 告警
日期: 2026-06-08
变更摘要
新增后台任务 server_offline_monitor(30s):当已监控子机由在线变为离线时,推送 一次 Telegram 告警,并写入 alert_logs、广播 WebSocket 刷新仪表盘。系统设置新增开关 notify_alert_offline。
动机
运维需要在 Agent 心跳丢失时主动获知,而非仅依赖仪表盘刷新;与现有 CPU/内存/磁盘告警开关模式一致。
涉及文件
server/background/server_offline_monitor.py(新)server/application/server_connectivity.pyserver/api/websocket.pyserver/infrastructure/telegram/__init__.pyserver/utils/notify_toggles.pyserver/config.pyserver/api/settings.pyserver/main.pyfrontend/src/types/api.tstests/test_server_offline_monitor.pydocs/design/specs/2026-06-08-server-offline-alert-design.mddocs/design/plans/2026-06-08-server-offline-alert.md
迁移 / 重启
- 无需 DB 迁移(设置键首次写入时落库)
- 需 重启后端 以启动新后台任务
验证方式
pytest tests/test_server_offline_monitor.py tests/test_server_connectivity.py -q
设置页关闭「子机离线告警」后,模拟在线→离线边沿应无 Telegram。