System Watchdog
System watchdog for your machine. Detect real, actionable anomalies and stay quiet about normal steady-state conditions. Auto-detects Linux vs macOS.
Goal
Optimize for few, high-signal alerts.
Do not alert on:
- - process age alone (long-running is not "stale")
- Docker/container/virtualization baseline memory usage
- absolute disk-used GB unless near a real limit
- generic top-process lists without an actual anomaly
Do alert on:
- - memory pressure that is worsening (swap growth, low available memory, macOS compressor pressure)
- runaway process growth (memory leak signals via delta tracking)
- sustained abnormal CPU burn (>2 cores for >15 min)
- disk pressure near a practical limit (>90% or <20 GB free)
How to Invoke
CODEBLOCK0
The script outputs JSON to stdout. Parse the output and decide whether to report.
Override the state file path: INLINECODE0
Output Format
CODEBLOCK1
Note: available is Linux-only (MemAvailable). free, inactive, compressed are macOS-only (vm_stat breakdown).
Detection Philosophy
1. Memory pressure, not just RAM usage
High RAM usage alone is noisy. The script tracks
swap growth since last run and low available/free memory as stronger signals. On macOS, high compressor usage with low free pages is also flagged.
2. Runaway behavior, not stale age
Never flag a process just because it has been running a long time. Look for memory growth (delta since last run) and sustained CPU instead.
3. Disk only when it matters
Ignore absolute disk usage. Only report disk when it is actually nearing a practical limit.
Agent Workflow
- 1. Run INLINECODE5
- Parse the JSON output
- If
suspicious is false → do nothing (no message) - If
suspicious is true → format a concise report - Lead with the verdict and the 1–3 most important findings
Report Format
CODEBLOCK2
Keep it short. Do not dump every top process unless it directly supports an issue.
State Tracking
The script persists lightweight state to ~/.openclaw/workspace/state/system-watchdog-state.json so it can detect changes since last run (swap growth, per-process memory growth) rather than only snapshot values.
系统看门狗
用于您机器的系统看门狗。检测真实、可操作的异常,对正常稳态保持静默。自动检测Linux与macOS。
目标
优化为少量、高信号告警。
不对以下情况告警:
- - 仅进程运行时长(长时间运行不等于过时)
- Docker/容器/虚拟化基线内存使用量
- 绝对磁盘已用GB数(除非接近实际限制)
- 无实际异常的通用进程列表
对以下情况告警:
- - 持续恶化的内存压力(交换空间增长、可用内存不足、macOS压缩器压力)
- 失控的进程增长(通过增量追踪检测内存泄漏信号)
- 持续异常CPU占用(超过2个核心且持续15分钟以上)
- 接近实际限制的磁盘压力(使用率>90%或剩余<20 GB)
调用方式
bash
bash ~/.openclaw/skills/system-watchdog/check.sh
脚本输出JSON到标准输出。解析输出并决定是否报告。
覆盖状态文件路径:SYSTEMWATCHDOGSTATE=/path/to/state.json
输出格式
json
{
suspicious: true,
verdict: watch|investigate|act_now|ok,
os: Darwin|Linux,
summary: {
ram: 19.3/32.0 GB (60.4%),
swap: 1.6/3.0 GB,
swap_delta: +0.2 GB,
load: 3.30/2.21/2.17,
cores: 10,
disk: 14/926 GB (3%),
available: 8.50 GB available,
free: 0.08 GB truly free,
inactive: 11.88 GB inactive/speculative,
compressed: 5.16 GB compressed
},
issues: [ ],
top_processes: [ ],
ignored_normals: [ ]
}
注意:available仅适用于Linux(MemAvailable)。free、inactive、compressed仅适用于macOS(vm_stat细分)。
检测原理
1. 内存压力,而非仅RAM使用率
仅高RAM使用率会产生噪音。脚本追踪
自上次运行以来的交换空间增长以及可用/空闲内存不足作为更强信号。在macOS上,高压缩器使用率配合低空闲页也会被标记。
2. 失控行为,而非运行时长
绝不因进程运行时间长而标记。关注内存增长(自上次运行以来的增量)和持续CPU占用。
3. 仅在必要时关注磁盘
忽略绝对磁盘使用量。仅在磁盘实际接近限制时报告。
代理工作流程
- 1. 运行check.sh
- 解析JSON输出
- 如果suspicious为false → 不执行任何操作(无消息)
- 如果suspicious为true → 格式化简洁报告
- 以判定结果和1-3个最重要发现开头
报告格式
⚠️ 系统看门狗 — 判定结果
重要性说明:
- - <来自issues[].why的1-3个简洁发现>
证据:
建议:
已忽略:进程运行时长、Docker基线、磁盘绝对使用量
保持简短。不要转储所有进程列表,除非直接支持某个问题。
状态追踪
脚本将轻量级状态持久化到~/.openclaw/workspace/state/system-watchdog-state.json,以便检测自上次运行以来的变化(交换空间增长、进程内存增长),而非仅快照值。