Monitors the CPU and memory load of the server, automatically controls the execution of system tasks, and prevents the server from downtime due to excessive load.
Use this skill when the user mentions the following situations:
| Parameter | Default Value | Description |
|---|---|---|
| ------ | -------- | ------ |
cpu_threshold | 90 | CPU load threshold (percentage) |
memory_threshold | 90 | Memory usage threshold (percentage) |
check_interval | 30 | Check interval (seconds) |
cool_down | 60 | Cool-down time after excessive load (seconds) |
# Quick check
python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py
# View detailed JSON output
python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py --json
# Custom thresholds
python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py --cpu-threshold 80 --memory-threshold 85
Before executing any resource-consuming tasks:
```bash
python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py --json
```
status: "ok" / "warning" / "critical"recommendation: "CONTINUE" / "PAUSE"cpu.load_percent: CPU load percentagememory.used_percent: Memory usage percentageFor long-running tasks, use the following pattern:
import subprocess
import time
import json
def check_load():
result = subprocess.run(
['python3', '~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py', '--json'],
capture_output=True, text=True
)
return json.loads(result.stdout)
def run_with_load_monitor(task_func, cpu_threshold=90, memory_threshold=90):
"""Continuously monitor load while executing tasks"""
while True:
status = check_load()
if status['status'] == 'critical':
print(f"⚠️ Excessive load, pausing task...")
print(f"CPU: {status['cpu']['load_percent']}%, Memory: {status['memory']['used_percent']}%")
time.sleep(60) # Wait for 60 seconds
continue
# Load is normal, execute the task
task_func()
break
| Exit Code | Status | Meaning |
|---|---|---|
| -------- | ------ | ------ |
| 0 | ok | Load is normal, can continue |
| 1 | warning | Load is relatively high, recommended to proceed with caution |
| 2 | critical | Load is excessively high, must pause |
For your 2-core 2GB server:
```bash
python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py --cpu-threshold 75 --memory-threshold 80
```
When a critical status is detected, you should:
{
"status": "critical",
"cpu": {
"load_avg_1m": 3.8,
"cpu_count": 2,
"load_percent": 190.0
},
"memory": {
"total_mb": 2048,
"used_mb": 1843,
"available_mb": 205,
"used_percent": 90.0
},
"top_processes": [
{"user": "node", "cpu_percent": 45.2, "mem_percent": 32.1, "command": "node /usr/bin/openclaw"}
],
"thresholds": {"cpu": 90, "memory": 90},
"recommendation": "PAUSE"
}
共 1 个版本