闲社服务运行正常AI智能体自动化平台
s

系统负载监控

技能标识:system-load-monitor

System load monitoring and task control skill. Monitors CPU and memory usage rates, automatically pauses tasks when the load exceeds the threshold, and resumes execution after the load recovers. Suitable for low-configured servers to prevent downtime.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

系统负载监控

系统负载监控

核心功能

监控服务器的CPU和内存负载,自动控制系统任务的执行,防止服务器因负载过高而宕机。

何时使用此技能

当用户提到以下情况时使用此技能:
  • - 服务器配置较低(如2核2GB),容易宕机
  • 需要执行资源密集型任务
  • 之前因负载过高导致过宕机
  • 需要智能控制任务执行节奏
  • 需要实时监控服务器状态

配置参数

参数默认值描述
cputhreshold90CPU负载阈值(百分比)
memorythreshold
90 | 内存使用率阈值(百分比) | | check_interval | 30 | 检查间隔(秒) | | cool_down | 60 | 负载过高后的冷却时间(秒) |

使用方法

1. 检查当前系统状态

bash

快速检查


python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py

查看详细JSON输出

python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py --json

自定义阈值

python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py --cpu-threshold 80 --memory-threshold 85

2. 任务执行前的负载检查流程

在执行任何消耗资源的任务之前:

  1. 1. 运行负载检查
bash python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py --json
  1. 2. 解析返回结果
- status: ok / warning / critical - recommendation: CONTINUE / PAUSE - cpu.load_percent: CPU负载百分比 - memory.used_percent: 内存使用率百分比
  1. 3. 根据状态做出决策
- ok: 继续执行任务 - warning: 谨慎执行,考虑分批处理 - critical: 暂停任务,冷却后重试

3. 长时间运行任务的监控循环

对于长时间运行的任务,使用以下模式:

python
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 runwithloadmonitor(taskfunc, cputhreshold=90, memorythreshold=90):
执行任务时持续监控负载
while True:
status = check_load()

if status[status] == critical:
print(f⚠️ 负载过高,暂停任务...)
print(fCPU: {status[cpu][loadpercent]}%, 内存: {status[memory][usedpercent]}%)
time.sleep(60) # 等待60秒
continue

# 负载正常,执行任务
task_func()
break

状态码说明

退出码状态含义
0ok负载正常,可以继续
1
warning | 负载较高,建议谨慎操作 | | 2 | critical | 负载过高,必须暂停 |

低配置服务器(2核2GB)建议

针对您的2核2GB服务器:

  1. 1. 降低阈值:建议使用70-80%作为警戒线
bash python3 ~/.openclaw/workspace/skills/system-load-monitor/scripts/check_load.py --cpu-threshold 75 --memory-threshold 80
  1. 2. 分批执行:将大任务拆分为小批次
  1. 3. 避免并发:每次只执行一个任务
  1. 4. 定期检查:长时间运行的任务每30秒检查一次负载

告警通知

当检测到critical状态时,您应该:

  1. 1. 立即暂停当前任务
  2. 通知用户(通过飞书消息)
  3. 冷却期后重试

脚本输出示例

json
{
status: critical,
cpu: {
loadavg1m: 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, cpupercent: 45.2, mempercent: 32.1, command: node /usr/bin/openclaw}
],
thresholds: {cpu: 90, memory: 90},
recommendation: PAUSE
}

注意事项

  1. 1. 此技能是一个独立的监控工具,不依赖Fairy的内置判断
  2. 在执行任何重要任务之前应调用检查
  3. 对于长时间运行的任务,应建立循环监控机制
  4. 阈值参数可根据实际情况调整

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 system-load-monitor-1776153188 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 system-load-monitor-1776153188 技能

通过命令行安装

skillhub install system-load-monitor-1776153188

下载

⬇ 下载 system-load-monitor v1.0.0(免费)

文件大小: 4.21 KB | 发布时间: 2026-4-15 13:57

v1.0.0 最新 2026-4-15 13:57
Initial release of system-load-monitor:

- Monitors server CPU and memory load in real time, automatically pausing tasks when load exceeds configured thresholds and resuming upon recovery.
- Provides command-line tools and Python code patterns for integrating load checks into workflows.
- Supports customizable thresholds and check intervals, suitable for low-configured servers.
- Includes structured JSON output and status codes for easy integration and alerting.
- Offers recommendations and usage notes tailored for servers prone to overload.
返回顶部