infra-guardian
System-level watchdog to keep agent infrastructure running.
Install
mkdir -p .claude/skills/infra-guardian && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16241" && unzip -o skill.zip -d .claude/skills/infra-guardian && rm skill.zipInstalls to .claude/skills/infra-guardian
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
OpenClaw Agent Infrastructure Guardian — keep your agent's infrastructure alive. Process lifecycle management with detached execution, auto-restart on failure. Cron scheduler health monitoring (per-job detection, auto-recovery). Direct Telegram/messaging alerts independent of OpenClaw. System-level watchdog that runs from crontab, not OpenClaw cron. Use when launching background processes, monitoring cron job health, or when things keep dying silently.Key capabilities
- →Launch and track background processes
- →Auto-restart processes on failure
- →Monitor OpenClaw cron job health per-job
- →Auto-recover by restarting gateway when cron scheduler stalls
- →Send direct Telegram alerts independent of OpenClaw
- →Check key process liveness via `pgrep`
How it works
The skill manages process lifecycles with detached execution and auto-restart, monitors cron job health by reading `jobs.json` from disk, and sends direct Telegram alerts if critical services fail, all independent of OpenClaw.
Inputs & outputs
When to use infra-guardian
- →Monitoring background processes
- →Ensuring cron job uptime
- →Setting up health alerts
About this skill
Infra Guardian
Keep your OpenClaw agent's infrastructure alive. Processes, cron jobs, the works.
What It Does
| Layer | What | How |
|---|---|---|
| Process Management | Launch, track, auto-restart background processes | setsid + nohup + registry + healthcheck |
| Cron Health | Detect stalled OpenClaw cron jobs per-job | Reads jobs.json from disk, checks nextRunAtMs vs interval |
| Auto-Recovery | Restart gateway when cron scheduler stalls | SIGUSR1 when >50% jobs overdue |
| Alerting | Telegram alerts independent of OpenClaw | Direct Bot API calls — works even if OpenClaw is down |
Core principle: Monitoring components must not depend on the system they monitor.
Quick Start
# Process management
bash scripts/managed-process.sh register my-bot "python3 /path/to/bot.py" 480
bash scripts/managed-process.sh start my-bot
bash scripts/managed-process.sh status
# Infrastructure watchdog (add to system crontab, NOT OpenClaw cron)
*/10 * * * * /path/to/scripts/managed-process.sh watchdog
Commands
| Command | Usage | Description |
|---|---|---|
register | register <name> <command> [duration_min] | Define a managed process. Duration 0 = indefinite. |
start | start <name> | Launch registered process (fully detached). |
stop | stop <name> | Graceful shutdown via SIGTERM. |
restart | restart <name> | Stop then start. |
status | status [name] | Show all processes or one specific. |
healthcheck | healthcheck | Check all registered processes, restart dead ones. |
watchdog | watchdog | Unified check: cron health + process health (for system crontab). |
cron-health | cron-health | Check OpenClaw cron scheduler per-job health. |
proc-health | proc-health | Check key process liveness (configurable patterns). |
deregister | deregister <name> | Remove process from registry + clean up files. |
Infrastructure Watchdog
The watchdog command is the unified health check. Run it from system crontab — never from OpenClaw cron (you can't monitor the scheduler using the scheduler).
# Unified (recommended)
bash scripts/managed-process.sh watchdog
# Individual checks
bash scripts/managed-process.sh cron-health
bash scripts/managed-process.sh proc-health
Cron Health (cron-health)
Reads OpenClaw's cron state directly from disk (~/.openclaw/cron/jobs.json). No API dependency.
Per-job detection:
- Each enabled job checked independently
nextRunAtMsoverdue by >2× its interval → STALE- Jobs with
kind: "every"use theireveryMsas interval - Jobs with
kind: "cron"use 24h as max expected interval
Auto-recovery:
- If >50% of jobs are stale → sends SIGUSR1 to restart gateway
- Alerts via Telegram Bot API directly (reads bot token from OpenClaw config)
- 30-minute cooldown between alerts (no spam)
Why this matters: OpenClaw has a known cron bug (#8424) where kind: "cron" jobs permanently stall after missing a run. This watchdog catches it within 20 minutes instead of discovering it 8 hours later.
Process Health (proc-health)
Checks known background processes via pgrep. Configurable patterns in the script.
- Alerts via Telegram if any monitored process is down
- 30-minute cooldown
Setup
# Add to system crontab (not OpenClaw cron!)
crontab -e
# Add this line:
*/10 * * * * /home/clawdbot/clawd/scripts/managed-process.sh watchdog
Process Management
The Problem
When AI agents launch background processes via exec & or nohup, those processes are tied to the parent session. Session ends → child processes get SIGTERM → die silently → nobody knows.
The Rule
ALL long-running processes MUST go through this framework. No exceptions.
- ❌
python script.py & - ❌
nohup python script.py & - ❌
execwithbackground: true - ✅
bash scripts/managed-process.sh register <name> <cmd>thenstart <name>
Detached Execution
Processes launch via setsid + nohup + disown, giving them:
- Own session ID (SID) — not tied to any terminal
- PPID=1 (init) — survives parent death
- Immune to SIGHUP/session cleanup
Health Monitoring
The healthcheck command (can run from cron every 5 min):
- Checks each registered process is alive (PID exists)
- If dead: checks if it completed normally (ran ≥80% of expected duration)
- If premature death: auto-restarts and writes alert flag
- Alert cooldown: 15 min between alerts (no spam)
Alert Integration
When a process dies, the healthcheck writes:
/tmp/process_monitor_alert.flag— trigger file/tmp/process_monitor_alert.txt— alert message
Configure your agent's heartbeat to check these files and forward alerts.
Process Registry
All processes are tracked in .process-registry.json:
{
"my-bot": {
"command": "python3 /path/to/bot.py",
"duration_min": 480,
"auto_restart": true,
"max_restarts": 5,
"restart_cooldown": 30
}
}
Signal Handling Best Practice
Your scripts should log signals, not silently exit:
import signal
from datetime import datetime
def handler(signum, frame):
sig_name = signal.Signals(signum).name
print(f"⚠️ SIGNAL: {sig_name} at {datetime.now()}", flush=True)
global shutdown
shutdown = True
signal.signal(signal.SIGTERM, handler)
signal.signal(signal.SIGINT, handler)
Never call sys.exit(0) in signal handlers — it makes crashes look like clean exits, preventing watchdogs from restarting.
Architecture
System Crontab (every 10 min)
└─ managed-process.sh watchdog
├─ cron-health: reads ~/.openclaw/cron/jobs.json
│ ├─ per-job: nextRunAtMs overdue > 2× interval?
│ ├─ if >50% stale → SIGUSR1 gateway restart
│ └─ alert → Telegram Bot API (direct, no OpenClaw)
└─ proc-health: pgrep known patterns
└─ alert → Telegram Bot API (direct, no OpenClaw)
Independence chain: System crontab → bash script → disk read → direct Telegram API. Zero OpenClaw dependencies in the monitoring path.
When not to use it
- →When monitoring components depend on the system they monitor
- →When launching long-running processes without using the managed framework
- →When `sys.exit(0)` is called in signal handlers, preventing restarts
Limitations
- →Monitoring components must not depend on the system they monitor.
- →All long-running processes MUST go through this framework.
- →Never call `sys.exit(0)` in signal handlers.
How it compares
This skill provides a system-level watchdog that runs from crontab, ensuring infrastructure uptime and sending independent alerts, which is more resilient than relying on OpenClaw's internal monitoring.
Compared to similar skills
infra-guardian side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| infra-guardian (this skill) | 0 | 5mo | Review | Advanced |
| observability-engineer | 12 | 4mo | No flags | Advanced |
| devops-troubleshooter | 1 | 4mo | No flags | Advanced |
| observability-monitoring-monitor-setup | 1 | 4mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by diegosouzapw
View all by diegosouzapw →You might also like
observability-engineer
sickn33
Build production-ready monitoring, logging, and tracing systems. Implements comprehensive observability strategies, SLI/SLO management, and incident response workflows. Use PROACTIVELY for monitoring infrastructure, performance optimization, or production reliability.
devops-troubleshooter
sickn33
Expert DevOps troubleshooter specializing in rapid incident response, advanced debugging, and modern observability. Masters log analysis, distributed tracing, Kubernetes debugging, performance optimization, and root cause analysis. Handles production outages, system reliability, and preventive monitoring. Use PROACTIVELY for debugging, incident response, or system troubleshooting.
observability-monitoring-monitor-setup
sickn33
You are a monitoring and observability expert specializing in implementing comprehensive monitoring solutions. Set up metrics collection, distributed tracing, log aggregation, and create insightful da
worker-health-monitoring
dadbodgeoff
Heartbeat-based health monitoring for background workers with configurable thresholds, rolling duration windows, failure rate calculation, and stuck job detection.
Logging and Monitoring for Agentic Workflows
Hack23
Comprehensive observability patterns for GitHub Agentic Workflows including structured logging, metrics collection, alerting strategies, debugging techniques, and production monitoring best practices for autonomous agent systems.
mimir
grafana
>