Files
Nexus/docs/audit/2026-06-14-watch-ssh-ring-baota.md
T
2026-07-08 22:31:31 +08:00

71 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 审计 — 监测探针 SSH 优先 + 移除 IO + 宝塔圆环 UI
**Changelog**:
- `docs/changelog/2026-06-14-watch-probe-ssh-first-no-io-skip.md`
- `docs/changelog/2026-06-14-watch-remove-io-metrics.md`
- `docs/changelog/2026-06-14-watch-metric-ring-baota-style.md`
**范围**:实时监测探针与槽卡片 UI,对齐宝塔 CPU/内存/磁盘/负载展示。
## 审计范围
| 文件 | 变更 | 状态 |
|------|------|------|
| `server/background/watch_probe_runner.py` | 5s 一律 SSH;去掉 IO 速率差分 | ☑ |
| `server/utils/watch_metrics.py` | merge/live 优先 SSH;去掉 bps | ☑ |
| `server/infrastructure/ssh/remote_probe.py` | 精简探针命令;load 补位 | ☑ |
| `tests/test_watch_metrics.py` | 适配无 IO / SSH 优先 | ☑ |
| `frontend/src/components/watch/WatchMetricRing.vue` | 新建圆环组件 | ☑ |
| `frontend/src/components/watch/WatchSlotCard.vue` | 三圆环 + 负载圆环 | ☑ |
| `frontend/src/components/watch/WatchProbeRecordsTable.vue` | 去掉 IO 列 | ☑ |
| `frontend/src/components/watch/WatchTrendChart.vue` | 去掉 IO 曲线 | ☑ |
| `frontend/src/components/watch/WatchSparkline.vue` | 去掉 IO 指标 | ☑ |
| `frontend/src/composables/useWatchPins.ts` | 类型去掉 bps | ☑ |
| `frontend/src/pages/WatchMetricsPage.vue` | 去掉 IO 展示 | ☑ |
| `frontend/src/utils/watchFormat.ts` | `metricRingColor` / `loadUsagePct` | ☑ |
| `frontend/src/components/watch/WatchMetricBar.vue` | 删除(横条弃用) | ☑ |
## Step 3 规则扫描
| H | 规则 | 结论 |
|---|------|------|
| H1 | SSH 凭据与命令注入 | SAFE — 仍走既有 `remote_probe` 封装;无用户输入拼入 shell |
| H2 | 探针频率与负载 | NOTE — 有 SSH 时每 5s 一次 SSH(与宝塔同源,用户明确要求) |
| H3 | 数据合并优先级 | SAFE — SSH 覆盖 Agent stale 心跳;SSH 全失败才回退 Agent |
| H4 | 前端 XSS | SAFE — 圆环仅数值与固定标签;tooltip 文本插值 |
| H5 | IO 字段移除 | SAFE — DB 列保留 NULLAPI 不再推送 bps |
| H6 | 密钥 / 凭据 | SAFE — 无 `.env` 或密钥变更 |
## Closure
| H | 判定 | 依据 |
|---|------|------|
| H1 | SAFE | `remote_probe.py` 固定 psutil 脚本 |
| H2 | 接受 | 用户要求与宝塔一致;仅监测开启槽 |
| H3 | SAFE | `merge_redis_and_ssh` CPU/mem/disk/load 优先 SSH |
| H4 | SAFE | `WatchMetricRing.vue``v-html` |
| H5 | SAFE | `to_live_dict` 无 bps 键 |
| H6 | SAFE | diff 无 secrets |
## 验证
| 项 | 结果 |
|----|------|
| `pytest tests/test_watch_metrics.py tests/test_watch_pins.py -q` | 22 passed(本机无 psutil 的 SSH 本地探针 1 skip/fail 为环境) |
| `cd frontend && npx vite build` | ✅ |
| `bash deploy/pre_deploy_check.sh` | 部署前执行 |
## DoD
- [x] changelog 三份(≥10 行)
- [x] 本审计含 Step 3 / Closure / DoD / 文件清单
- [x] `vite build` 通过
- [ ] 提交并 push
- [ ] 生产 `/health` ok、`/app/` 200
- [ ] 浏览器终验:`#/watch-metrics` 圆环与宝塔数值接近
## 部署说明
- **后端 + 前端**:需 API 重启(Docker upgrade+ `vite build` 同步 `web/app`
- **无** 数据库迁移