Files
Nexus/docs/changelog/2026-07-02-agent-cpu-sampling.md
T
2026-07-08 22:31:31 +08:00

1.2 KiB
Raw Blame History

Agent 2.1.1:监测模式 CPU 采样优化

日期2026-07-02

变更摘要

修复四槽实时监测下 CPU 曲线长期显示 0% 的问题:

  1. 新增 web/agent/cpu_metrics.py:监测模式用 interval=None 测约 5s 窗口(与心跳间隔对齐);首次进入 watch 用 1s bootstrap
  2. agent.py 升至 v2.1.1_build_system_info 改用 sample_watch_cpu_bundle(含 per_cpu_pct
  3. 升级/安装脚本同步下载 cpu_metrics.py

动机

v2.1.0 监测模式用 psutil.cpu_percent(interval=0.3),低负载机器常四舍五入为 0;内存/负载正常,属采样窗口过短而非探针故障。

涉及文件

  • web/agent/cpu_metrics.py(新建)
  • web/agent/agent.py — v2.1.1
  • server/application/server_batch_common.py — curl 下载 cpu_metrics
  • tests/test_agent_cpu_metrics.py(新建)

迁移

  • 中心:部署后 /agent/cpu_metrics.py 可访问
  • 子机:Pin 且开实时监测的机器点槽内「升级 Agent」至 2.1.1

验证

.venv/bin/pytest tests/test_agent_cpu_metrics.py tests/test_agent_watch_mode.py -q

升级后探针 cpu_pct 在低负载下应出现非零小幅波动,不再长期贴 0。