结论
- 直接原因:另一个 Hermes 桌面会话(default profile,session
local-f8a9762c4558cf577cfb8a0d66aea297a48de1a15b103fe017c416fdda59c00a,“hermes-bot-二次初始化机器人”)在 10:41:18 CST 后台启动unify_aux.py,批量并发写 11 个 profile 的 auxiliary 配置。 - 资源峰值:10:42-10:43 CST,16 核整体平均 CPU 忙碌率约 80.4% / 87.0%;systemd 记账为
30min 20.375s CPU time over 2min 54.708s wall clock,平均约 10.4 核,叠加原有基线负载后接近全核跑满。 - 当前状态:该 scope 于 10:44:13 CST 正常退出(exit 0),CPU 已回落至 ~10% busy / ~88% idle,无需干预。
时间线(实测)
| 时间 (CST) | 事件 | 证据 |
|---|---|---|
| 10:41:18 | systemd-run 启动后台脚本 | Started [systemd-run] ... /s500data/envs/ju314/bin/python /home/cat/.hermes/cache/scratch/unify_aux.py ... |
| 10:42:00 | 全核忙碌率升至 80.4% | Prometheus node_cpu_seconds_total{instance="max2"},1m rate 聚合 |
| 10:43:00 | 全核忙碌率峰值 87.0% | 同上 |
| 10:44:13 | worker scope 正常结束 | hermes-worker-proc_2bb9b3d73c38.scope: Consumed 30min 20.375s CPU time over 2min 54.708s wall clock time, 616.2M memory peak. |
| 10:45+ | CPU 回落至正常基线 | Grafana/Prometheus 10:45 为 14.5%,之后 ~9-12% |
Prometheus CPU 证据(instance=max2,1m avg)
| 时间 | 忙碌率 | 时间 | 忙碌率 |
|---|---|---|---|
| 10:38 | 17.4% | 10:42 | 80.4% |
| 10:39 | 20.3% | 10:43 | 87.0% |
| 10:40 | 15.5% | 10:44 | 52.6% |
| 10:41 | 34.0% | 10:45 | 14.5% |
查询:100 * (1 - avg(rate(node_cpu_seconds_total{instance="max2",mode="idle"}[1m]))),数据源 http://100.118.25.124:9090(Prometheus/VictoriaMetrics API)。
根因
- 脚本:
/home/cat/.hermes/cache/scratch/unify_aux.py(2010 bytes,10:41:13 创建) - 执行方式:Hermes 后台进程
proc_2bb9b3d73c38,由 default 桌面会话local-f8a9762c4558cf577cfb8a0d66aea297a48de1a15b103fe017c416fdda59c00a发起 - 并发模型:
ThreadPoolExecutor(max_workers=11),11 个 profile 并发 - 工作量:11 profiles × 22 auxiliary roles × 3 fields(
provider/model/base_url)= 726 次hermes config setCLI 调用 - CPU 放大原因:每次
hermes config set都拉起完整 CLI/Python 进程,启动开销主导;726 次调用 × ~2.5 CPU 秒/次 ≈ 1815 CPU 秒,与 systemd 记账 1820 CPU 秒吻合
关键证据
systemd journal
11月 27 10:41:18 max2-nixos systemd[13117]: Started [systemd-run] ... /s500data/envs/ju314/bin/python /home/cat/.hermes/cache/scratch/unify_aux.py 2>&1 | tee /home/cat/.hermes/cache/scratch/unify_aux.stdout
11月 27 10:44:13 max2-nixos systemd[13117]: hermes-worker-proc_2bb9b3d73c38.scope: Consumed 30min 20.375s CPU time over 2min 54.708s wall clock time, 616.2M memory peak.
进程结果记录(/home/cat/.hermes/logs/process-results/proc_2bb9b3d73c38.json)
{
"id": "proc_2bb9b3d73c38",
"command": "/s500data/envs/ju314/bin/python /home/cat/.hermes/cache/scratch/unify_aux.py 2>&1 | tee .../unify_aux.stdout",
"task_id": "session:agent:main:local:dm:local-f8a9762c4558cf577cfb8a0d66aea297a48de1a15b103fe017c416fdda59c00a",
"exit_code": 0,
"completion_reason": "exited"
}
脚本输出摘要
profile=im roles=22 writes=66 failures=0
profile=itarch roles=22 writes=66 failures=0
profile=trader roles=22 writes=66 failures=0
profile=algoengineer roles=22 writes=66 failures=0
profile=opsengineer roles=22 writes=66 failures=0
profile=tester roles=22 writes=66 failures=0
profile=developer roles=22 writes=66 failures=0
profile=default roles=22 writes=66 failures=0
profile=quantassistant roles=22 writes=66 failures=0
profile=trialuser roles=22 writes=66 failures=0
profile=riskcontrol roles=22 writes=66 failures=0
ALL_OK=True FAILURES=0
排除项
- Docker 容器:排查时 docker stats 未见异常高 CPU 容器(grafana-node ~5%,其余均低);容器非本次全核峰值来源。
- proc_2d403be8e8db:10:40:32 结束,4min9s CPU / 4min15s wall,约 1 核,时间与幅度不匹配。
- 恶意/异常入侵迹象:未见对应异常进程;峰值进程链可追溯到用户发起的 Hermes 配置统一任务。
观测缺口(本次排查中发现)
- auditd:未运行,仅有
kauditd内核线程。 - sysstat/pidstat:主机未安装,缺少进程级历史 CPU 采样;本次依赖 Prometheus node_cpu + systemd cgroup 记账 + Hermes process-results 回溯定位。
建议
- 批量
hermes config set任务将并发度从 11 降到 2-4,或改为直接编辑配置文件后一次性校验,避免 700+ 次 CLI 进程启动风暴。 - 如需事后定位“刚才是谁跑满 CPU”,建议补齐
sysstat(pidstat/sar)或启用 atop 历史采样;仅有 node_exporter 聚合 CPU 指标时,只能看到峰值,难直接归因进程。