secubox-openwrt/package/secubox/secubox-app-watchdog/files/etc/init.d/watchdog
CyberMind-FR 66d9fbc6c0 feat(watchdog): Add service health monitor with auto-recovery
New packages for monitoring and auto-restarting critical services:

secubox-app-watchdog:
- watchdogctl CLI: status, check, check-recover, watch, restart-*
- Monitors LXC containers: haproxy, mitmproxy-in/out, streamlit
- Monitors host services: crowdsec, uhttpd, dnsmasq
- Checks HTTPS endpoints: gk2.secubox.in, admin.gk2, lldh360.maegia.tv
- Auto-recovery with alert cooldown and log rotation
- Procd service + cron fallback for redundancy

luci-app-watchdog:
- Real-time dashboard with 10s polling
- Container/service tables with restart buttons
- Endpoint health indicators
- Alert log viewer with refresh/clear
- RPCD backend: status, restart_*, check, get_logs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-12 06:46:53 +01:00

43 lines
760 B
Bash

#!/bin/sh /etc/rc.common
START=99
STOP=10
USE_PROCD=1
NAME="watchdog"
PROG="/usr/sbin/watchdogctl"
start_service() {
local enabled
config_load watchdog
config_get enabled main enabled '0'
[ "$enabled" = "1" ] || {
echo "Watchdog is disabled. Enable with: uci set watchdog.main.enabled=1"
return 0
}
procd_open_instance
procd_set_param command "$PROG" watch
procd_set_param respawn 3600 5 5
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param pidfile /var/run/watchdog.pid
procd_close_instance
echo "Watchdog started"
}
stop_service() {
echo "Watchdog stopped"
}
reload_service() {
stop
start
}
service_triggers() {
procd_add_reload_trigger "watchdog"
}