openclaw-sentinel is a unified watchdog and backup service for OpenClaw gateways.
It replaces separate watchdog and backup timers with one scheduler-driven entrypoint that:
- Performs strict health checks against
/healthz({"ok": true}required) - Runs deterministic recovery before coding-agent repair
- Runs system + memory backups on schedule
- Verifies backup freshness and sends deduplicated alerts
- Preserves incident state in atomic JSON files
Sentinel runs as a periodic oneshot job (launchd on macOS, systemd timer on Linux):
- Acquire lock (
state/sentinel.lock) with stale detection - Load unified config (
sentinel.json) and state (sentinel-state.json) - Probe health (
/healthz, fallbackopenclaw gateway status --json) - If healthy: run backup cycle (if due), then backup health check
- If unhealthy: run tiered recovery with incident tracking
- Release lock
Recovery tiers are strictly ordered:
openclaw gateway restartopenclaw doctor --fix --non-interactive- Config rollback from backup
- Coding agent repair (Codex/Claude)
- Telegram rescue mode
Before tier 3+ actions, sentinel verifies backup freshness and creates an emergency backup if needed.
Core modules in scripts/lib/:
config.sh: config defaults, loading, helper getters, legacy migrationstate.sh: JSON state init/read/write, incident lifecycle, backup snapshot metadatalock.sh: lock acquire/release, stale detection by PID + agehealth.sh: strict health probe and fallback probe,wait_for_oknotify.sh: unified Telegram + Discord notificationsrecovery.sh: tier escalation, cooldown logic, agent resolution, rescue modebackup.sh: schedule checks, system backup, manifest generation, dedup alertsbackup-memory.sh: memory/session backup snapshotstg-helper.sh: Telegram runtime helper for rescue-mode agent workflows
Main entrypoint: scripts/sentinel.sh.
curl -fsSL https://raw.githubusercontent.com/bkochavy/openclaw-sentinel/main/install.sh | bashgit clone https://github.com/bkochavy/openclaw-sentinel.git
cd openclaw-sentinel
./install.sh# interactive setup wizard
./install.sh --setup
# non-interactive setup (OPENCLAW_SENTINEL_CHAT_ID optional)
./install.sh --setup --quiet
# migrate legacy watchdog/backup configs into sentinel.json
./install.sh --migrate
# verify installation only
./install.sh --checkopenclawbashcurljqgit
Default config path: ~/.openclaw/sentinel.json.
Full example: sentinel.example.json.
| Key | Type | Default | Purpose |
|---|---|---|---|
health_url |
string | http://127.0.0.1:18789/healthz |
Primary gateway health endpoint |
check_interval_seconds |
int | 300 |
Scheduler interval metadata |
state_file |
string(path) | ~/.openclaw/state/sentinel-state.json |
Runtime state JSON |
lock_file |
string(path) | ~/.openclaw/state/sentinel.lock |
Concurrency lock JSON |
recovery_log |
string(path) | ~/.openclaw/workspace/memory/recovery-log.md |
Recovery journal path |
log_dir |
string(path) | ~/.openclaw/logs |
Sentinel logs directory |
| Key | Type | Default |
|---|---|---|
max_failures_before_action |
int | 2 |
cooldown_seconds |
int | 1800 |
max_repairs_per_incident |
int | 3 |
deterministic_restart_enabled |
bool | true |
deterministic_doctor_enabled |
bool | true |
config_rollback_enabled |
bool | true |
codex_timeout_seconds |
int | 180 |
rescue_timeout_seconds |
int | 420 |
rescue_command_prefix |
string | /codex |
codex_model |
string | o4-mini |
codex_bin |
string(path) | "" |
claude_bin |
string(path) | "" |
| Key | Type | Default |
|---|---|---|
enabled |
bool | true |
schedule |
string (HH:MM) |
04:00 |
system_backup_dir |
string(path) | ~/backups/openclaw-system |
memory_backup_dir |
string(path) | ~/backups/openclaw-memory |
github_repo |
string | "" |
github_user |
string | "" |
include_skills |
bool | true |
include_scripts |
bool | true |
include_launchd |
bool | true |
include_agents |
bool | true |
redact_env_values |
bool | true |
max_backup_age_hours |
int | 30 |
critical_files |
string[] | openclaw/openclaw.json, workspace-config/AGENTS.md, workspace-config/SOUL.md |
| Key | Type | Default |
|---|---|---|
telegram_bot_token_env |
string | TELEGRAM_BOT_TOKEN_AVA |
telegram_chat_id |
string | "" |
discord_webhook_url |
string | "" |
notify_on_recovery |
bool | true |
notify_on_backup_failure |
bool | true |
notify_on_backup_success |
bool | false |
Run scripts/sentinel.sh directly (or installed ~/.openclaw/bin/sentinel.sh):
| Flag | Behavior |
|---|---|
| (none) | Normal health + recovery + backup flow |
--backup-only |
Skip health/recovery, run backup cycle |
--health-only |
Skip backup cycle, run health/recovery |
--force-backup |
Force backup regardless of schedule |
--dry-run |
Log mutating actions without executing them |
--status |
Print current JSON state |
--reset-incident |
Clear current incident and failure counter |
--migrate |
Build sentinel.json from legacy configs |
--help |
Print usage |
Sentinel supports legacy watchdog.json and backup.json migration.
Recommended cutover:
- Install sentinel with migration:
./install.sh --migrate- Confirm sentinel config exists:
cat ~/.openclaw/sentinel.json- Verify scheduler health:
./install.sh --check- Confirm old watchdog/backup timers are unloaded (installer handles this automatically). On macOS, the installer also strips a stale
StartCalendarIntervalblock from the legacy watchdog plist so duplicate launches do not survive migration.
sentinel_config_load behavior:
- Uses
sentinel.jsonwhen present - Else merges legacy watchdog + backup config fields
- Else uses built-in defaults
Run module tests (TAP-style shell scripts):
bash tests/test_health.sh
bash tests/test_state.sh
bash tests/test_lock.sh
bash tests/test_config.sh
bash tests/test_notify.sh
bash tests/test_tg_helper.sh
bash tests/test_recovery.sh
bash tests/test_backup.sh
bash tests/test_sentinel_flags.sh
bash tests/test_integration.sh- Fork and create a feature branch.
- Keep
scripts/lib/*.shfocused and under 200 lines where possible. - Add or update tests for every behavior change.
- Run all tests before opening a PR.
- Keep dependencies limited to
bash,curl,jq, andgit.
Coding standards:
- Use JSON state/config updates through
jq. - Use atomic writes (
tmp+mv) for mutable files. - Never
sourcewritable state files. - Keep deterministic recovery tiers before LLM escalation.
# keep config
./uninstall.sh
# also remove ~/.openclaw/sentinel.json
./uninstall.sh --purge