Files
Nexus/docs/changelog/2026-06-12-server-watch-slots.md
T
Nexus Agent b46922fe92 feat(watch): 4 槽实时监测 — 5s 探针、WS、历史页与告警联动
宝塔式自选子机监测:Pin CRUD、全指标 SSH/Redis 探针、探针落库、
/ws/watch 推送、监测历史与进程抽屉;Agent 可选附带 net/disk IO。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-12 02:56:37 +08:00

2.0 KiB
Raw Blame History

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__.pyWatchPinSession / WatchPin / WatchProbeRecord(含 processes_json
  • server/infrastructure/database/migrations.py — 三表 + processes_json
  • server/infrastructure/database/watch_repo.py
  • server/application/services/watch_service.py
  • server/api/watch.py — pins / live / metrics / probe-records / sessions / processes
  • server/background/watch_probe_runner.py — 5s 探针、10s 进程、告警、Redis 窗口
  • server/api/websocket.py/ws/watch + nexus:watch
  • server/utils/watch_metrics.py / watch_alerts.py
  • server/infrastructure/ssh/remote_probe.py
  • server/main.py
  • web/agent/agent.py — 心跳附带 net/disk IO

前端

  • frontend/src/composables/useWatchPins.ts
  • frontend/src/components/watch/*
  • frontend/src/pages/WatchMetricsPage.vue
  • frontend/src/pages/ServersPage.vue — 槽位行 + 列表「+」
  • frontend/src/router/index.ts / App.vue

测试

  • tests/test_watch_metrics.py
  • tests/test_watch_pins.py

迁移 / 重启

  • 启动时自动 DDLwatch_* 表)
  • 重启 APIprimary worker 启动 watch_probe 5s 任务)
  • 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 槽替换对话框。