b46922fe92
宝塔式自选子机监测:Pin CRUD、全指标 SSH/Redis 探针、探针落库、 /ws/watch 推送、监测历史与进程抽屉;Agent 可选附带 net/disk IO。 Co-authored-by: Cursor <cursoragent@cursor.com>
2.0 KiB
2.0 KiB
Changelog — 服务器实时监测槽(M1+M2+M3,无 CSV)
日期:2026-06-12
类型:新功能
摘要
实现宝塔式 4 槽实时监测:5s 探针、WebSocket 推送、Pin CRUD、历史趋势与探针记录 Tab、进程 Top5 抽屉;M3 含 Agent 心跳附带 net_io/disk_io(减 SSH)及监测探针告警联动。不含 CSV 导出(按产品要求跳过)。
动机
运维需在服务器页对自选少数子机做近实时 CPU/内存/磁盘/网络/磁盘 IO 监视,并保留可回溯探针记录。
涉及文件
后端
server/domain/models/__init__.py—WatchPinSession/WatchPin/WatchProbeRecord(含processes_json)server/infrastructure/database/migrations.py— 三表 +processes_json列server/infrastructure/database/watch_repo.pyserver/application/services/watch_service.pyserver/api/watch.py— pins / live / metrics / probe-records / sessions / processesserver/background/watch_probe_runner.py— 5s 探针、10s 进程、告警、Redis 窗口server/api/websocket.py—/ws/watch+nexus:watchserver/utils/watch_metrics.py/watch_alerts.pyserver/infrastructure/ssh/remote_probe.pyserver/main.pyweb/agent/agent.py— 心跳附带 net/disk IO
前端
frontend/src/composables/useWatchPins.tsfrontend/src/components/watch/*frontend/src/pages/WatchMetricsPage.vuefrontend/src/pages/ServersPage.vue— 槽位行 + 列表「+」frontend/src/router/index.ts/App.vue
测试
tests/test_watch_metrics.pytests/test_watch_pins.py
迁移 / 重启
- 启动时自动 DDL(
watch_*表) - 需 重启 API(primary worker 启动
watch_probe5s 任务) - Agent 升级后心跳才带 IO(可选,减 SSH)
验证
pytest tests/test_watch_metrics.py tests/test_watch_pins.py -q
cd frontend && npm run type-check
bash scripts/local_verify.sh
浏览器:服务器页 Pin → 5s 内指标更新;#/watch-metrics 趋势 + 探针记录;满 4 槽替换对话框。