40 lines
1.0 KiB
Markdown
40 lines
1.0 KiB
Markdown
|
|
# 审计 — Agent 2.1.1 CPU 采样
|
||
|
|
|
||
|
|
**Changelog**: `docs/changelog/2026-07-02-agent-cpu-sampling.md`
|
||
|
|
|
||
|
|
## Step 3 规则扫描
|
||
|
|
|
||
|
|
| 文件 | 规则 | 结论 |
|
||
|
|
|------|------|------|
|
||
|
|
| `cpu_metrics.py` | watch 首次 1s bootstrap,后续 interval=None 对齐 ~5s 心跳 | PASS |
|
||
|
|
| `agent.py` | 进入 watch 时 `reset_watch_cpu_bootstrap()` | PASS |
|
||
|
|
| `server_batch_common` | 升级命令含 cpu_metrics.py | PASS |
|
||
|
|
| 常态 60s 心跳 | 仍用 `sample_cpu_percent(watch_mode=False)` | PASS |
|
||
|
|
|
||
|
|
## Closure
|
||
|
|
|
||
|
|
| 项 | 状态 |
|
||
|
|
|----|------|
|
||
|
|
| CPU 曲线长期 0% | 监测模式改长窗口采样 |
|
||
|
|
| 双模心跳 | 不变,仍 5s/60s |
|
||
|
|
| 旧 Agent 2.1.0 | 可继续用,仅 CPU 显示偏 0 |
|
||
|
|
|
||
|
|
## 文件清单
|
||
|
|
|
||
|
|
- `web/agent/cpu_metrics.py`
|
||
|
|
- `web/agent/agent.py`
|
||
|
|
- `server/application/server_batch_common.py`
|
||
|
|
- `tests/test_agent_cpu_metrics.py`
|
||
|
|
|
||
|
|
## DoD
|
||
|
|
|
||
|
|
- [x] pytest cpu_metrics + watch_mode 通过
|
||
|
|
- [x] AGENT_VERSION 2.1.1
|
||
|
|
- [x] 升级脚本拉取 cpu_metrics.py
|
||
|
|
|
||
|
|
## 验证
|
||
|
|
|
||
|
|
```bash
|
||
|
|
.venv/bin/pytest tests/test_agent_cpu_metrics.py tests/test_agent_watch_mode.py -q
|
||
|
|
```
|