返回顶部
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
安全检测
已通过
303
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

system-load-monitor

系统负载监控

核心功能

监控服务器的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.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部