health 命令
获取运行中网关的健康状态。
用法
bash
moltbot health [选项]选项
| 选项 | 描述 |
|---|---|
--json | JSON 格式输出 |
--timeout <ms> | 超时时间(毫秒) |
--verbose | 详细输出 |
示例
基本健康检查
bash
moltbot health详细输出
bash
moltbot health --verboseJSON 输出(用于监控脚本)
bash
moltbot health --json输出示例
✅ Gateway Health: healthy
Server: running
Uptime: 2d 4h 32m
Memory: 245 MB
CPU: 12%
Channels:
- whatsapp: connected
- telegram: connected
Plugins: 3 activeJSON 输出格式
json
{
"status": "healthy",
"server": {
"running": true,
"uptime": 185520,
"memory": 245000000,
"cpu": 12.5
},
"channels": {
"whatsapp": "connected",
"telegram": "connected"
},
"plugins": {
"active": 3
}
}监控集成
健康检查脚本
bash
#!/bin/bash
# health-check.sh
if ! moltbot health --timeout 5000 | grep -q "healthy"; then
echo "Moltbot is unhealthy!"
moltbot gateway restart
fiCron 监控
bash
# 每5分钟检查健康状态
*/5 * * * * moltbot health --json >> /var/log/moltbot-health.log