status-monitor

Polar Sponsor
爱发电 赞助
.NET 9.0

管理OpenClaw Agent状态上传脚本,定期同步代理在线状态至云监控平台

两个运行模式. 模式1: 克隆同步( 默认).

功能概述

两个运行模式. 模式1: 克隆同步( 默认).是一项面向实际任务的技能,主要用于OpenClaw 的内置 cron 执行脚本 :. 绊脚石短语 : 说"同步状态", "重起同步" 或 "QQ"。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。

核心要点

  • 使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。
  • 该技能适合需要稳定复用相关能力的场景,可作为自动化工作流的一部分,也便于后续检查、调整和扩展。
  • 从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。

使用与执行

实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。

结果检查与注意事项

执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。

脚本位置

~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py

两种运行模式

模式 1:Cron 定时同步(默认)

OpenClaw 内置的 cron 定期执行该脚本:

python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py

触发语句:说“sync status”、“restart sync”或“同步状态”、“重启同步状态”——OpenClaw 将按计划触发执行。

模式 2:守护进程模式(Daemon Mode)

使用 --fork 启动真正的后台守护进程:

命令 说明
python3 scripts/status_uploader.py start --fork 启动守护进程
python3 scripts/status_uploader.py start --fork --interval 10 以自定义间隔(单位:分钟)启动
python3 scripts/status_uploader.py stop 停止服务
python3 scripts/status_uploader.py status 检查服务状态
python3 scripts/status_uploader.py set-interval 设置同步间隔
python3 scripts/status_uploader.py test 单次测试上传

示例:

# 启动守护进程
python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py start --fork

# 以 10 分钟间隔启动
python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py start --fork --interval 10

触发条件

满足以下任一条件时即触发:

  1. 首次初始化:说“enable status monitor”、“setup status-monitor”或“启用状态监控”、“开启监控同步”、“配置 status-monitor”
  2. 手动触发:说“sync status”、“sync status-monitor”、“upload status”或“同步状态”、“同步 status-monitor”、“上传状态” → 单次执行
  3. 定时同步:由 OpenClaw cron 触发 → 单次执行
  4. 检查状态:说“check status monitor”、“monitor status”、“check upload service”或“查看状态监控”、“状态监控状态”、“检查上传服务”
  5. 停止服务:说“stop status monitor”、“stop upload service”或“停止状态监控”、“停止上传服务”
  6. 修改同步间隔:说“sync every 10 minutes”、“change to 15 minutes”或“每10分钟同步一次”、“改成15分钟”
  7. 守护进程模式:说“start status monitor”、“start daemon”、“run in background”或“启动状态监控”、“启动守护进程”、“后台运行” → 执行 start --fork

其他触发语句:说“start status-monitor service”、“restart status-monitor service”或“启动status-monitor服务”、“重启status-monitor服务”。

初始化流程(首次使用时必须执行)

步骤 1:检查 Token 配置

技能运行时,首先按以下顺序查找 token:

  1. 环境变量 MONITOR_PLATFORM_TOKEN
  2. 文件 ~/.openclaw/credentials/openclaw-status-monitor.json

步骤 2:Token 缺失处理

若未找到 token,则引导用户完成注册/登录:

  1. 向用户提示:

    No monitoring token found. Let me help you set up...
    
    Please choose a sign-in method:
    1. Existing user: visit https://openclaw-agent-monitor.vercel.app and click Sign In
    2. New user: visit https://openclaw-agent-monitor.vercel.app and click Sign Up
    
    After signing in:
    - Go to the Settings page
    - Generate and copy your Agent Token
    - Send me the generated token
    
  2. 等待用户回复 token

  3. 保存 token:

    • 创建目录 ~/.openclaw/credentials/
    • 写入文件 ~/.openclaw/credentials/openclaw-status-monitor.json:
      {
        "agentToken": "user-provided-token",
        "createdAt": "2026-03-29T10:00:00.000Z",
        "monitorUrl": "https://openclaw-agent-monitor.vercel.app"
      }
      
  4. 校验 token

步骤 3:Token 校验成功后

✅ Token configured successfully!

Starting upload service...
- Running initial sync test...
- ✅ Service started successfully!

Monitor platform: https://openclaw-agent-monitor.vercel.app
Upload interval: 5 minutes

Start command:
python3 scripts/status_uploader.py start --fork

Management commands:
- Say "sync status" to manually trigger an upload
- Say "check status monitor" to check service status
- Say "stop status monitor" to stop the service
- Say "restart status monitor" to restart the service

核心功能:上传脚本管理

1. 检查脚本是否存在

if [ -f ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py ]; then
  echo "Script exists"
else
  echo "Script not found"
fi

2. 启动服务(推荐)

# 使用 --fork 启动守护进程(推荐)
python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py start --fork --interval 10

3. 设置同步间隔

# 方法 1:启动时指定
python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py start --fork --interval 15

# 方法 2:使用 set-interval 命令
python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py set-interval 15

4. 停止服务

python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py stop

5. 检查服务状态

python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py status

6. 查看错误日志

~/.openclaw/logs/status_uploader_error.log
~/.openclaw/logs/status_uploader.log
# 查看最近 50 行错误日志
tail -50 ~/.openclaw/logs/status_uploader_error.log

# 查看服务日志
tail -50 ~/.openclaw/logs/status_uploader.log

日志轮转:当日志文件超过 10MB 时自动轮转,格式为:status_uploader.20260329_183500.log

7. 手动触发单次上传

python3 ~/.openclaw/skills/openclaw-status-monitor/scripts/status_uploader.py test

上传逻辑(简化版)

该脚本仅从 openclaw.json 中读取全部 agent ID 并上传 —— 不执行任何离线检测。

离线检测由监控平台(openclaw-agent-monitor)负责:

  • 平台根据上传时间自动更新 lastActiveTimestamp
  • 若连续 5 分钟以上未收到上传,平台将自动标记该 agent 为离线

存储配置

Token 存储位置

~/.openclaw/credentials/openclaw-status-monitor.json:

{
  "agentToken": "e2d3262f-b626-4850-af11-5f2cb1c0dcad",
  "createdAt": "2026-01-26T10:00:00.000Z",
  "monitorUrl": "https://openclaw-agent-monitor.vercel.app",
  "syncIntervalMinutes": 5
}

日志路径

  • 服务日志:~/.openclaw/logs/status_uploader.log
  • 错误日志:~/.openclaw/logs/status_uploader_error.log
  • PID 文件:~/.openclaw/logs/status_uploader.pid
  • Token 配置:~/.openclaw/credentials/openclaw-status-monitor.json

错误处理

1. Token 缺失

初始化期间:

❌ No monitoring token detected

Please complete these steps first:

1. Visit https://openclaw-agent-monitor.vercel.app
2. Click Sign In / Sign Up to log in or register
3. After logging in, generate an Agent Token on the Settings page
4. Send me the token

Example: My token is abc123-def456...

2. 脚本未找到

❌ Upload script not found

Please reinstall the skill or contact the developer.

3. 服务启动失败

请检查错误日志:

cat ~/.openclaw/logs/status_uploader_error.log

常见错误:

  • Token 未配置
  • 网络连接失败
  • 端口已被占用

4. Token 无效

❌ Token validation failed

Your token may have expired or is invalid.

Please obtain a new token:
1. Log in to https://openclaw-agent-monitor.vercel.app
2. Go to the Settings page
3. Click Generate to create a new Token
4. Send me the new token

对话示例

首次启用

用户: 启用状态监控 / enable status monitor Agent: Checking monitoring configuration...

❌ No Agent Token detected

Please complete these steps first:

  1. Visit https://openclaw-agent-monitor.vercel.app
  2. Click Sign In(支持 Google/GitHub 等)
  3. 登录后,在 Settings 页面生成 Agent Token
  4. Send me the token

用户: 我的 Token 是 e2d3262f-b626-4850-af11-5f2cb1c0dcad / My token is e2d3262f-b626-4850-af11-5f2cb1c0dcad Agent: Validating token...

✅ Token validated successfully!

Starting upload service...

  • Running initial sync test...
  • ✅ Service started successfully!

✅ Status monitor enabled!

  • Monitor platform: https://openclaw-agent-monitor.vercel.app
  • Upload interval: 5 minutes
  • Service status: running

Management commands:

  • Say "sync status" / "同步状态" to manually trigger an upload
  • Say "check status monitor" / "查看状态监控" to check service status
  • Say "stop status monitor" / "停止状态监控" to stop the service

检查服务状态

用户: 查看状态监控 / check status monitor Agent: Checking upload service status...

✅ Service is running PID: 12345 Sync interval: 5 minutes Log file: ~/.openclaw/logs/status_uploader.log

Recent logs:

2026-03-29 10:30:01 - INFO - Upload success: ['main', 'coding']
2026-03-29 10:35:02 - INFO - Upload success: ['main', 'coding']

Error log: none

停止服务

用户: 停止状态监控 / stop status monitor Agent: Stopping upload service...

✅ Service stopped

To restart, say "start status monitor" / "启动状态监控".

手动同步

用户: 同步状态 / sync status Agent: Executing manual upload...

Online agents: ['main', 'coding'] Upload result: ✅ Success

重启服务

用户: 重启状态监控 / restart status monitor Agent: Restarting upload service...

✅ Service restarted, PID: 67890

检查错误日志

用户: 查看状态监控错误日志 / check status monitor error log Agent: Checking error logs...

Recent errors:

2026-03-29 09:15:03 - HTTP 401: Unauthorized
2026-03-29 09:20:01 - Network: [Errno 8] nodename nor servname provided

Suggestion: Check if the token is correct, or check your network connection.

相关专题

更多
Postman身份认证怎么配置
Postman身份认证怎么配置

本专题从实际API接口调试场景出发,讲解Postman身份认证的完整配置流程,包括常见认证协议介绍、授权参数设置、访问令牌填写、OAuth 2.0授权及认证失败排查,帮助用户正确完成接口授权与访问验证。

2026.11.06

0

12

Postman请求头Headers怎么设置
Postman请求头Headers怎么设置

围绕Postman HTTP请求头配置展开,讲解Headers选项的具体使用方式,包括Key和Value参数填写、请求头信息添加、常见Header字段设置及请求头修改方法,帮助用户解决接口调试过程中遇到的请求头配置问题。

2026.11.06

0

13

Postman接口请求发送教程
Postman接口请求发送教程

详细介绍Postman接口请求的创建与发送方法,涵盖GET和POST请求、URL配置、请求参数、Headers请求头、Body请求体设置以及响应结果查看,帮助用户掌握Postman接口请求的完整操作流程。

2026.11.06

0

10

DBeaver怎么导入数据
DBeaver怎么导入数据

DBeaver数据导入专题,整理Excel、CSV、SQL、TXT等常见文件的数据导入方法,涵盖目标数据库选择、数据表创建、字段映射、数据类型设置及导入参数配置等操作,帮助用户将本地文件中的数据写入数据库,并了解批量导入、重复数据处理和导入失败等常见问题的解决方法。

2026.11.05

0

12

DBeaver安全防护教程大全
DBeaver安全防护教程大全

DBeaver安全防护专题,围绕数据库连接安全、账号密码保护和访问权限管理展开,整理SSL/TLS加密连接、SSH隧道、数据库凭据保存及证书验证等配置方法,同时介绍敏感信息保护、远程连接风险和高权限账号使用等注意事项,帮助用户提高数据库日常管理的安全性。

2026.11.05

0

12

DBeaver连接创建与配置教程
DBeaver连接创建与配置教程

本专题聚焦DBeaver数据库连接配置与管理,覆盖从新建连接、选择数据库类型到填写连接参数和验证连接的完整流程。针对MySQL、PostgreSQL、SQL Server等常见数据库,整理相应的连接设置方法,并提供驱动缺失、认证失败和连接异常等问题的排查方向。

2026.11.04

0

16

XORM框架结构体映射与表结构同步
XORM框架结构体映射与表结构同步

本专题围绕XORM框架的结构体映射展开,说明表名与字段的命名策略、xorm标签常用属性、主键自增与时间字段自动填充,并演示Sync2自动建表、增量字段升级、索引声明与反向生成结构体的完整流程。

2026.11.04

0

15

XORM框架安装配置与数据库连接
XORM框架安装配置与数据库连接

本专题聚焦XORM框架的配置与连接环节,拆解MySQL、PostgreSQL、SQLite、SQL Server的DSN写法与驱动选择,讲清连接池参数、多数据源拆分、读写分离与超时重连的处理方式,并补充容器与兼容数据库的适配经验。

2026.11.04

0

15

XORM框架安装配置与数据库连接
XORM框架安装配置与数据库连接

本专题聚焦XORM框架的配置与连接环节,拆解MySQL、PostgreSQL、SQLite、SQL Server的DSN写法与驱动选择,讲清连接池参数、多数据源拆分、读写分离与超时重连的处理方式,并补充容器与兼容数据库的适配经验。

2026.11.04

0

16

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
热门推荐
/
最新课程
phpStudy极速入门视频教程
phpStudy极速入门视频教程

共6课时 | 54.7万人学习

独孤九贱(4)_PHP视频教程
独孤九贱(4)_PHP视频教程

共89课时 | 134.3万人学习