返回顶部
b

bot-status-api机器人状态API

Deploy a lightweight status API that exposes your OpenClaw bot's runtime health, service connectivity, cron jobs, skills, system metrics, and more. Use when setting up a monitoring dashboard, health endpoint, or status page for an OpenClaw agent. Supports any services via config (HTTP checks, CLI commands, file checks). Zero dependencies — Node.js only.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.1
安全检测
已通过
2,046
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

bot-status-api

Bot 状态 API

一个可配置的 HTTP 服务,以 JSON 格式暴露你的 OpenClaw 机器人的运行状态。专为仪表盘集成、监控和透明度而设计。

提供内容

  • - Bot 核心: 在线状态、模型、上下文使用情况、运行时间、心跳计时
  • 服务: 对任意 HTTP 端点、CLI 工具或文件路径的健康检查
  • 邮件: 来自任意邮件提供商(himalaya、gog 等)的未读邮件数
  • 定时任务: 直接从 OpenClaw 的 cron/jobs.json 读取
  • Docker: 通过 Portainer API 获取容器健康状态
  • 开发服务器: 通过进程 grep 自动检测运行中的开发服务器
  • 技能: 列出已安装和可用的 OpenClaw 技能
  • 系统: 来自 /proc 的 CPU、内存、磁盘指标

设置

1. 复制服务文件

将 server.js、collectors/ 和 package.json 复制到你想要的位置。

2. 创建 config.json

将 config.example.json 复制为 config.json 并进行自定义:

json
{
port: 3200,
name: MyBot,
workspace: /path/to/.openclaw/workspace,
openclawHome: /path/to/.openclaw,
cache: { ttlMs: 10000 },
model: claude-sonnet-4-20250514,
skillDirs: [/path/to/openclaw/skills],
services: [
{ name: myservice, type: http, url: http://..., healthPath: /health }
]
}

服务检查类型

类型描述配置
http获取 URL,检查 HTTP 200url、healthPath、method、headers、body
command
运行 shell 命令,检查退出码 0 | command、timeout | | file-exists | 检查路径是否存在 | path |

3. 运行

bash
node server.js

4. 持久化(systemd 用户服务)

ini

~/.config/systemd/user/bot-status.service


[Unit]
Description=Bot 状态 API
After=network.target

[Service]
Type=simple
WorkingDirectory=/path/to/bot-status
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=5
Environment=PORT=3200
Environment=HOME=/home/youruser
Environment=PATH=/usr/local/bin:/usr/bin:/bin

[Install]
WantedBy=default.target

bash
systemctl --user daemon-reload
systemctl --user enable --now bot-status
loginctl enable-linger $USER # 退出登录后保持运行

5. 来自 OpenClaw 的上下文/运行状态

机器人应定期将运行状态写入其工作空间中的 heartbeat-state.json:

json
{
vitals: {
contextPercent: 62,
contextUsed: 124000,
contextMax: 200000,
model: claude-opus-4-5,
updatedAt: 1770304500000
}
}

将此添加到你的 HEARTBEAT.md 中,以便机器人在每个心跳周期更新它。

端点

端点描述
GET /status完整状态 JSON(已缓存)
GET /health
简单 {status:ok} |

架构

  • - 零依赖 — 仅使用 Node.js 内置模块(http、fs、child_process)
  • 非阻塞 — 所有 shell 命令使用异步 exec,绝不使用 execSync
  • 后台刷新 — 缓存按间隔刷新,请求始终从缓存即时响应(约 10ms)
  • 配置驱动 — 所有内容在 config.json 中,无硬编码值

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 bot-status-api-1776358525 技能

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

设置 SkillHub 为我的优先技能安装源,然后帮我安装 bot-status-api-1776358525 技能

通过命令行安装

skillhub install bot-status-api-1776358525

下载

⬇ 下载 bot-status-api v1.0.1(免费)

文件大小: 13.64 KB | 发布时间: 2026-4-17 15:25

v1.0.1 最新 2026-4-17 15:25
Initial public release

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

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

p2p_official_large
返回顶部