← 返回
效率工具 中文

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 resum...
系统负载监控和任务控制技能。监控CPU和内存使用率,当负载超过阈值时自动暂停任务,并在负载恢复正常时自动恢复任务执行。
hifengzy
效率工具 clawhub v1.0.0 1 版本 99830.5 Key: 无需
★ 0
Stars
📥 589
下载
💾 7
安装
1
版本
#latest

概述

System Load Monitor

Core Functions

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.

When to Use This Skill

Use this skill when the user mentions the following situations:

  • The server has low configuration (e.g., 2 cores 2GB) and is prone to downtime
  • Need to execute resource-intensive tasks
  • Previous downtime caused by excessive load
  • Need to intelligently control the rhythm of task execution
  • Need to monitor server status in real time

Configuration Parameters

ParameterDefault ValueDescription
--------------------
cpu_threshold90CPU load threshold (percentage)
memory_threshold90Memory usage threshold (percentage)
check_interval30Check interval (seconds)
cool_down60Cool-down time after excessive load (seconds)

Usage Methods

1. Check Current System Status

# 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

2. Load Check Process Before Task Execution

Before executing any resource-consuming tasks:

  1. Run load check

```bash

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

```

  1. Parse return results
    • status: "ok" / "warning" / "critical"
    • recommendation: "CONTINUE" / "PAUSE"
    • cpu.load_percent: CPU load percentage
    • memory.used_percent: Memory usage percentage
  1. Make decisions based on status
    • ok: Continue executing the task
    • warning: Execute cautiously and consider batch processing
    • critical: Pause the task and retry after cooling down

3. Monitoring Loop for Long-Running Tasks

For 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

Status Code Explanation

Exit CodeStatusMeaning
--------------------
0okLoad is normal, can continue
1warningLoad is relatively high, recommended to proceed with caution
2criticalLoad is excessively high, must pause

Recommendations for Low-Configured Servers (2 Cores 2GB)

For your 2-core 2GB server:

  1. Lower the threshold: It is recommended to use 70-80% as the warning line

```bash

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

```

  1. Execute in batches: Split large tasks into small batches
  1. Avoid concurrency: Only perform one task at a time
  1. Regular checks: Check the load every 30 seconds for long-running tasks

Alert Notifications

When a critical status is detected, you should:

  1. Immediately pause the current task
  2. Notify the user (via Feishu message)
  3. Retry after the cool-down period

Script Output Example

{
  "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"
}

Notes

  1. This skill is an independent monitoring tool and does not rely on Fairy's built-in judgment
  2. The check should be invoked before executing any important tasks
  3. For long-running tasks, a cyclic monitoring mechanism should be established
  4. Threshold parameters can be adjusted according to actual conditions

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 16:58 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

productivity

Weather

steipete
获取当前天气和预报(无需API密钥)
★ 445 📥 226,302
productivity

Obsidian

steipete
操作 Obsidian 仓库(纯 Markdown 笔记)并通过 obsidian-cli 自动化。
★ 432 📥 103,787
productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 438 📥 147,664