Files

66 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

# 审计 — 服务器实时监测槽(M1+M2+M3,无 CSV
**Changelog**: `docs/changelog/2026-06-12-server-watch-slots.md`
**设计**: `docs/design/specs/2026-06-12-server-watch-slots-design.md`
## 范围(文件清单)
| 文件 | 变更 |
|------|------|
| `server/domain/models/__init__.py` | WatchPinSession / WatchPin / WatchProbeRecord |
| `server/infrastructure/database/migrations.py` | watch_* 表 + processes_json |
| `server/infrastructure/database/watch_repo.py` | Pin CRUD、探针/会话查询 |
| `server/application/services/watch_service.py` | 业务编排 |
| `server/api/watch.py` | REST API |
| `server/background/watch_probe_runner.py` | 5s 探针、进程、告警 |
| `server/api/websocket.py` | `/ws/watch` |
| `server/utils/watch_metrics.py` / `watch_alerts.py` | 指标与告警联动 |
| `server/infrastructure/ssh/remote_probe.py` | SSH 全量探针 + 进程 |
| `server/main.py` | 路由 + watch_probe 任务 |
| `web/agent/agent.py` | 心跳 net_io/disk_ioM3 可选) |
| `frontend/src/composables/useWatchPins.ts` | Pin + WS |
| `frontend/src/components/watch/WatchSlotRow.vue` | 槽位行 |
| `frontend/src/components/watch/WatchSlotCard.vue` | 单槽卡片 |
| `frontend/src/components/watch/WatchSparkline.vue` | 迷你折线 |
| `frontend/src/components/watch/WatchProcessDrawer.vue` | 进程 Top5 |
| `frontend/src/components/watch/WatchTrendChart.vue` | 历史趋势 |
| `frontend/src/components/watch/WatchProbeRecordsTable.vue` | 探针记录表 |
| `frontend/src/utils/watchFormat.ts` | 速率格式化 |
| `frontend/src/pages/WatchMetricsPage.vue` | 监测历史 |
| `frontend/src/pages/ServersPage.vue` | 槽位行 + 列表 + |
| `frontend/src/router/index.ts` / `App.vue` | 路由与导航 |
| `server/api/servers.py` | 移除未使用 import |
| `tests/test_watch_metrics.py` / `test_watch_pins.py` | 单测 |
## Step 3 规则扫描
| H | 规则 | 结论 |
|---|------|------|
| H1 | 安全 | PASS — admin 隔离 Pin/探针记录;WS JWT |
| H2 | 无静默吞错 | PASS — 探针失败 INSERT + error 字段 |
| H3 | 无新密钥 | PASS |
| H4 | CUD 审计 | PASS — watch_pin_add/remove/replace |
## Closure
| H | 判定 | 依据 |
|---|------|------|
| H1H4 | PASS | Depends(get_current_admin);探针每 5s 落库 |
## DoD
- [x] local_verify
- [x] pytest test_watch_*
- [x] frontend type-check
- [ ] 生产浏览器:Pin 后 5s 指标更新、#/watch-metrics
## 验证
```bash
bash scripts/local_verify.sh
.venv/bin/pytest tests/test_watch_metrics.py tests/test_watch_pins.py -q
cd frontend && npm run type-check
```
未 Pin 子机无额外 SSH;满 4 槽替换对话框;Agent 升级可选(减 SSH,非强制)。