Uptime Kuma Skill 用于与 Uptime Kuma 监控服务器进行交互,通过一个封装了 Socket.IO API 的命令行工具来管理监控项。
用途 该技能适用于检查监控状态、添加或删除监控项、暂停或恢复检查、查看心跳历史等运维监控场景。
主要能力
- 查看整体状态摘要
- 列出所有监控项(支持 JSON 输出)
- 获取指定监控项详情
- 添加监控项,支持指定名称、类型、URL、主机名、端口、间隔等参数
- 暂停或恢复监控项
- 删除监控项
- 查看指定时间范围的心跳历史
- 列出通知渠道
支持的监控类型包括:http(HTTP/HTTPS 端点)、ping(ICMP ping)、port(TCP 端口检查)、keyword(HTTP + 关键词搜索)、dns(DNS 解析)、docker(Docker 容器)、push(推送式被动监控)、mysql、postgres、mongodb、redis(数据库检查)、mqtt(MQTT 代理)、group(监控分组)。
使用方式 需要安装 uptime-kuma-api Python 包:
pip install uptime-kuma-api
需设置以下环境变量(可在 shell 或 ThinkFleetBot 配置中设置):
- UPTIME_KUMA_URL:服务器 URL,例如 http://localhost:3001
- UPTIME_KUMA_USERNAME:登录用户名
- UPTIME_KUMA_PASSWORD:登录密码
脚本位置:scripts/kuma.py
常用命令示例:
整体状态摘要
python scripts/kuma.py status
列出所有监控项
python scripts/kuma.py list python scripts/kuma.py list --json
获取监控项详情
python scripts/kuma.py get <id>
添加监控项
python scripts/kuma.py add --name "My Site" --type http --url https://example.com python scripts/kuma.py add --name "Server Ping" --type ping --hostname 192.168.1.1 python scripts/kuma.py add --name "SSH Port" --type port --hostname server.local --port 22
暂停/恢复监控项
python scripts/kuma.py pause <id> python scripts/kuma.py resume <id>
删除监控项
python scripts/kuma.py delete <id>
查看心跳历史
python scripts/kuma.py heartbeats <id> --hours 24
列出通知渠道
python scripts/kuma.py notifications
常见工作流
- 检查哪些服务宕机:先运行 status,再运行 list 查找红色标记。
- 添加 30 秒间隔的 HTTP 监控:python scripts/kuma.py add --name "API Health" --type http --url https://api.example.com/health --interval 30
- 维护模式(暂停全部):通过 list --json 结合 jq 提取所有 id,循环执行 pause。
适用场景 适用于需要以命令行方式批量或自动化管理 Uptime Kuma 监控项的运维与开发场景。
限制 使用前必须安装 uptime-kuma-api 包并正确配置环境变量;具体功能受 Uptime Kuma 服务器及 API 支持范围限制。