Install
openclaw skills install failure-monitorAutomated failure detection, diagnosis, and auto-repair system for cron jobs. Monitors task health, fixes common issues automatically, and requests human confirmation when needed.
openclaw skills install failure-monitor智能守护你的定时任务系统
lastStatus: error)cron: job execution timed outChannel is required, unknown job idPermission denied, Access deniedAPI key invalid, Rate limit exceededNetwork timeout, Connection refusedScript not found, Syntax error可自动修复的问题(无需人工确认):
chmod +x)需要人工确认的问题:
将 failure-monitor 设置为定时任务,定期检查所有 cron jobs:
openclaw cron add \
--name "failure-monitor" \
--cron "*/30 * * * *" \
--tz "Asia/Shanghai" \
--session isolated \
--wake now \
--deliver \
--message "运行 failure-monitor: 检查所有定时任务状态,自动修复可修复的问题,需要人工时推送确认请求。报告格式用中文。"
运行频率:
0 * * * *)当收到失败通知时,手动运行诊断:
node /Users/xufan65/.openclaw/workspace/skills/failure-monitor/scripts/diagnose.cjs
查看最近的监控和修复记录:
cat /Users/xufan65/.openclaw/workspace/memory/failure-monitor-log.json
┌─────────────────┐
│ Cron Job 失败 │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 错误检测器 │
│ - 检查状态 │
│ - 提取错误 │
│ - 统计次数 │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 智能诊断器 │
│ - 分析错误类型 │
│ - 检查配置 │
│ - 生成方案 │
└────────┬────────┘
│
▼
能自动修复?
│
┌────┴────┐
Yes No
│ │
▼ ▼
┌───────┐ ┌──────────┐
│自动修复│ │推送确认 │
│- 执行 │ │- 详情 │
│- 记录 │ │- 等待 │
└───┬───┘ └────┬─────┘
│ │
▼ ▼
┌─────────────────┐
│ 推送报告 │
│ - 修复结果 │
│ - 需要操作 │
│ - 日志记录 │
└─────────────────┘
| 错误类型 | 错误信息 | 修复方案 | 人工确认 |
|---|---|---|---|
| 超时 | job execution timed out | 增加 timeout(120s → 300s) | ❌ 否 |
| 推送配置 | Channel is required | 更新 delivery.channel | ❌ 否 |
| 权限 | Permission denied | chmod +x script | ❌ 否 |
| 重复任务 | 重复的 cron job | 删除重复的任务 | ❌ 否 |
| API Key | API key invalid | 需要更新 API Key | ✅ 是 |
| 脚本错误 | Script not found | 需要修复脚本 | ✅ 是 |
| 网络错误 | Network timeout | 需要检查网络 | ✅ 是 |
config/rules.json定义自动修复规则:
{
"autoFixRules": [
{
"errorPattern": "job execution timed out",
"action": "increaseTimeout",
"params": {
"from": 120,
"to": 300
}
},
{
"errorPattern": "Channel is required",
"action": "updateDeliveryChannel",
"params": {
"channel": "discord"
}
}
],
"notifyRules": {
"autoFixSuccess": true,
"needConfirmation": true,
"cooldownMinutes": 60
}
}
# ✅ 自动修复成功
**任务**: deals-noon
**问题**: 超时(120秒)
**修复**: 增加超时到 300 秒
**时间**: 2026-03-12 14:00:00
**详情**:
- 任务运行时间超过原超时设置
- 已自动将 timeout 从 120s 增加到 300s
- 下次运行应该正常
# ⚠️ 需要人工介入
**任务**: content-research
**问题**: API Key 失效
**时间**: 2026-03-12 14:00:00
**错误详情**:
Error: TAVILY_API_KEY is invalid Please update your API key
**建议操作**:
1. 检查 TAVILY_API_KEY 环境变量
2. 更新到有效的 API Key
3. 重启任务
**回复 "确认" 执行修复,或 "忽略" 跳过**
skills/failure-monitor/
├── SKILL.md # 技能说明
├── scripts/
│ ├── monitor.cjs # 主监控脚本
│ ├── diagnose.cjs # 诊断脚本
│ ├── auto-fix.cjs # 自动修复脚本
│ └── notify.cjs # 通知脚本
├── config/
│ └── rules.json # 自动修复规则
└── package.json # 依赖管理
A: failure-monitor 使用 OpenClaw 内置的 Failure Alert,失败时会直接通知你。
A: 查看日志文件:
cat /Users/xufan65/.openclaw/workspace/memory/failure-monitor-log.json
A: 修改 config/rules.json,将 autoFixRules 设为空数组:
{
"autoFixRules": []
}
欢迎提交 Issue 和 Pull Request!
GitHub: https://github.com/sunnyhot/failure-monitor
🎉 让你的定时任务系统更加健壮和可靠!