- Cloned jlgrimes/openclaw-watchdog and modified - Added telegram_send() and gotify_send() functions - Modified send_sos() and send_recovery() for multi-channel - Updated setup.sh to configure Telegram/Gotify - All notification channels work simultaneously - Ready to install and run as systemd service
3.1 KiB
3.1 KiB
🦞 openclaw-watchdog
A standalone watchdog service for OpenClaw that monitors the gateway, auto-recovers from crashes, and sends Discord alerts when things go sideways.
What It Does
- Health monitoring — Polls the gateway health endpoint at a configurable interval
- Auto-restart — Restarts the gateway on first failure detection
- Config rollback — Reverts to last-known-good config if a simple restart doesn't work
- Discord SOS alerts — Sends a detailed alert with SSH instructions when all recovery fails
- Recovery notifications — Lets you know when the gateway comes back online
- No spam — Only alerts once per incident
Recovery Flow
Health check fails
│
▼
┌─────────────┐
│ Stage 1: │──→ Simple restart
│ Restart │
└──────┬──────┘
│ still failing
▼
┌─────────────┐
│ Stage 2: │──→ Revert config to last-known-good + restart
│ Rollback │
└──────┬──────┘
│ still failing
▼
┌─────────────┐
│ Stage 3: │──→ Discord SOS with hostname & SSH instructions
│ SOS Alert │
└─────────────┘
When the gateway recovers at any point, a ✅ recovery message is sent.
Prerequisites
- OpenClaw installed with
openclawCLI available - Linux with systemd
curlandjq- Discord bot token (optional, for alerts)
Quick Install
git clone https://github.com/jlgrimes/openclaw-watchdog.git
cd openclaw-watchdog
chmod +x setup.sh watchdog.sh
./setup.sh
The installer will:
- Copy
watchdog.shto~/.openclaw/ - Create a config file at
~/.openclaw/watchdog.env - Set up and start a systemd service
Configuration
All settings live in ~/.openclaw/watchdog.env (created by the installer):
| Variable | Default | Description |
|---|---|---|
HEALTH_URL |
http://localhost:3000/health |
Gateway health endpoint |
CHECK_INTERVAL |
30 |
Seconds between health checks |
FAIL_THRESHOLD |
3 |
Consecutive failures before SOS |
OPENCLAW_CONFIG_PATH |
~/.openclaw/config.yaml |
Path to OpenClaw config |
DISCORD_CHANNEL_ID |
(none) | Discord channel for alerts |
DISCORD_BOT_TOKEN |
(none) | Discord bot token for alerts |
After editing, restart the service:
sudo systemctl restart openclaw-watchdog
Manual Usage
You can also run the watchdog directly:
export DISCORD_BOT_TOKEN="your-token"
export DISCORD_CHANNEL_ID="your-channel-id"
./watchdog.sh
Managing the Service
sudo systemctl status openclaw-watchdog # Check status
sudo systemctl restart openclaw-watchdog # Restart
sudo systemctl stop openclaw-watchdog # Stop
tail -f ~/.openclaw/watchdog.log # View logs
License
Credits
Built by Jared Grimes and Claw 🦞 (an OpenClaw AI assistant)