diff --git a/docs/audit/2026-06-12-watch-install-psutil-ssh.md b/docs/audit/2026-06-12-watch-install-psutil-ssh.md new file mode 100644 index 00000000..54ba803c --- /dev/null +++ b/docs/audit/2026-06-12-watch-install-psutil-ssh.md @@ -0,0 +1,36 @@ +# 审计 — 监测槽 SSH 安装 psutil + +**日期**:2026-06-12 +**Changelog**: `docs/changelog/2026-06-12-watch-install-psutil-ssh.md` + +## 范围 + +| 文件 | +|------| +| `server/utils/psutil_install.py` | +| `server/application/services/watch_service.py` | +| `server/api/watch.py` | +| `frontend/src/components/watch/WatchSlotCard.vue` | +| `frontend/src/components/watch/WatchSlotRow.vue` | +| `frontend/src/utils/watchFormat.ts` | +| `server/utils/watch_probe_errors.py` | +| `tests/test_psutil_install.py` | +| `tests/test_watch_pins.py` | + +## Step 3 + +| H | 结论 | +|---|------| +| H1 鉴权 | PASS — 须 JWT;仅已 Pin 的服务器可安装 | +| H2 吞错 | PASS — SSH/安装失败 422 + snackbar | +| H4 审计 | PASS — `watch_install_psutil` | + +## Closure + +H1–H4 PASS + +## DoD + +- [x] pytest test_psutil_install + test_watch_pins +- [x] npm run type-check +- [ ] 生产浏览器:psutil 错误时出现按钮且安装后探针恢复 diff --git a/docs/changelog/2026-06-12-watch-install-psutil-ssh.md b/docs/changelog/2026-06-12-watch-install-psutil-ssh.md new file mode 100644 index 00000000..4f6c6799 --- /dev/null +++ b/docs/changelog/2026-06-12-watch-install-psutil-ssh.md @@ -0,0 +1,40 @@ +# Changelog — 监测槽一键 SSH 安装 psutil + +**日期**:2026-06-12 + +## 摘要 + +监测槽探针报「子机未安装 psutil」时,卡片内显示 **「安装 psutil(SSH)」** 按钮,通过 SSH 在子机系统 Python 安装 psutil(pip --user → apt/yum → pip)。 + +## 动机 + +SSH 监测探针依赖系统 `python3` 的 psutil;Agent venv 内的 psutil 无法被探针脚本使用。手动 SSH 安装成本高。 + +## 变更 + +- 后端:`POST /api/watch/servers/{server_id}/install-psutil`(须已 Pin 该服务器) +- `server/utils/psutil_install.py`:远程安装脚本 + 验证 +- 前端:`WatchSlotCard` 在 psutil 错误时显示按钮;`WatchSlotRow` 调用 API 并 refresh +- 审计:`watch_install_psutil` + +## 涉及文件 + +- `server/utils/psutil_install.py`(新) +- `server/application/services/watch_service.py` +- `server/api/watch.py` +- `frontend/src/components/watch/WatchSlotCard.vue` +- `frontend/src/components/watch/WatchSlotRow.vue` +- `frontend/src/utils/watchFormat.ts` +- `tests/test_psutil_install.py`(新) +- `tests/test_watch_pins.py` + +## 迁移 / 重启 + +- 无需迁移;需重启 API + 前端构建 + +## 验证 + +```bash +.venv/bin/pytest tests/test_psutil_install.py tests/test_watch_pins.py -q +cd frontend && npm run type-check +``` diff --git a/frontend/src/components/watch/WatchSlotCard.vue b/frontend/src/components/watch/WatchSlotCard.vue index 9d3ba872..f3530852 100644 --- a/frontend/src/components/watch/WatchSlotCard.vue +++ b/frontend/src/components/watch/WatchSlotCard.vue @@ -1,11 +1,12 @@