feat(watch): 监测槽开关、8h/24h、到期暂停与探针修复

支持随时暂停/恢复实时监测并保留槽位;TTL 到期自动暂停不占删槽;修复到期竞态导致空槽与唯一约束冲突;探针 parse_error 与中文错误;移除失败 snackbar。
This commit is contained in:
Nexus Agent
2026-06-12 03:47:56 +08:00
parent 7bb85aac41
commit 32a1885f0d
26 changed files with 1437 additions and 126 deletions
@@ -0,0 +1,41 @@
# 监测槽 parse_error 修复
**日期**: 2026-06-11
## 摘要
修复监测槽显示 `parse_error` 的常见路径:Agent 有心跳但缺 IO 时 SSH 补采失败导致整轮探针失败。
## 根因
- `redis_sample_has_io` 为 false 时强制走 SSHSSH JSON 解析失败且无完整 Redis IO 时返回 `parse_error`
- 已装 Agent 的机器通常有 CPU/内存心跳,不应因 SSH 失败而整轮失败
- SSH 脚本在 `getloadavg`/`net_io_counters` 异常时可能无 JSON 输出
## 修复
- Agent 有 CPU/内存时优先用 RedisSSH 仅补充 IOSSH 失败仍显示 Agent 指标
- SSH 探针脚本增加 try/exceptJSON 解析支持行内 `{` 前缀噪声
- 前端 `parse_error` 显示为「探针解析失败」,并展示 `metrics.error` 详情
## 2026-06-11 补充:错误中文提示
- 新增 `server/utils/watch_probe_errors.py`,新探针失败写入中文 `error`
- 前端 `formatProbeError` / `probeStatusLabel` / `probeSourceLabel` 统一中文(含历史英文记录)
- 监测历史探针记录表:状态筛选与错误列中文化
## 涉及文件
- `server/background/watch_probe_runner.py`
- `server/utils/watch_metrics.py`
- `server/infrastructure/ssh/remote_probe.py`
- `frontend/src/utils/watchFormat.ts`
- `frontend/src/components/watch/WatchSlotCard.vue`
- `tests/test_watch_metrics.py`
## 验证
```bash
pytest tests/test_watch_metrics.py -q
cd frontend && npm run type-check
```