Auto-reboot tooling for unstable home routers that freeze and need manual restarts.
This setup worked on the following device:
- Software Version:
RP2656 - Hardware Version:
WKF2.134.285F4G - Device Model:
AN5506-04-F (Fiberhome) - Device Description:
GPON
-
router_reboot.py
Replays router login + reboot flow (/goform/webLoginthen/goform/reboot). -
router_reboot_benchmark.py
Runs repeated reboot timing tests and records milestone timings to CSV. -
router_watchdog.py
Long-running watchdog that:- waits until internet has been working,
- triggers recovery only when
1.1.1.1fails for30sstraight (configurable), - requests a router reboot,
- waits forever for
eth0link down/up transition, - retries
1.1.1.1for50swith backoff, - if still down, reboots again and repeats,
- logs every attempt + outage duration to CSV,
- optionally posts Discord embeds (started/outage/diagnostics/stopped).
router_reboot.pyrouter_reboot_benchmark.pyrouter_watchdog.pyinstall.shsystemd/router-watchdog.servicesystemd/router-watchdog.env.example
Create a local env file (for manual runs):
cp .env.example .envThen edit .env with your values.
For systemd, copy and edit:
sudo cp systemd/router-watchdog.env.example /etc/router-watchdog.env
sudo nano /etc/router-watchdog.envSingle reboot:
python3 router_reboot.py --router 192.168.1.1 --username admin --password admin --verbose3x benchmark:
python3 router_reboot_benchmark.py --iterations 3 --interface eth0 --csv reboot_timings.csvWatchdog (manual):
python3 router_watchdog.pyWebhook test only (no monitoring loop):
python3 router_watchdog.py --test-webhookSimulated outage/reboot flow webhook test (includes multiple reboot attempts before recovery):
python3 router_watchdog.py --test-webhook-flow --test-webhook-reboots 3All webhook types test (sends one example of every embed type):
python3 router_watchdog.py --test-webhook-allWebhook URL can be passed via --discord-webhook or DISCORD_WEBHOOK_URL.
During real outage recovery, when internet stays down after a reboot, the watchdog:
- writes a CSV row with state
ping_recovery_timeout_rebooting_again, - sends a
🔄 Router Reboot Diagnosticswebhook withreboot_status=recovery_timeout, - sends another reboot request and repeats.
The 🚨 Network Outage Logged webhook is sent only when internet actually recovers.
Webhook types currently emitted by the watchdog:
▶️ Monitoring Script Started🛑 Monitoring Script Gracefully Stopped🚨 Network Outage Logged🔄 Router Reboot Diagnostics⚠️ Monitored Interface Missing✅ Monitored Interface Found📝 Log Path Fallback Activated🧪 Webhook Test
Webhook test modes (mutually exclusive):
--test-webhook: single🧪 Webhook Testembed--test-webhook-flow: simulated started -> repeated reboot diagnostics -> outage logged -> stopped flow--test-webhook-all: one example of every webhook type
--test-webhook-reboots N controls how many reboot diagnostics are sent during --test-webhook-flow (default: 3).
Install:
REPO_PATH=/absolute/path/to/routerrecuscitator
sudo "$REPO_PATH"/install.shUpdate (run again from a newer checkout):
REPO_PATH=/absolute/path/to/routerrecuscitator
sudo "$REPO_PATH"/install.shManual install/update with explicit path (if you do not use the script):
REPO_PATH=/absolute/path/to/routerrecuscitator
sudo mkdir -p /opt/routerrecuscitator
sudo cp -a "$REPO_PATH"/. /opt/routerrecuscitator/
sudo ln -sf /opt/routerrecuscitator/systemd/router-watchdog.service /etc/systemd/system/router-watchdog.service
sudo systemctl daemon-reload
sudo systemctl enable --now router-watchdog.service
sudo systemctl restart router-watchdog.serviceManage:
sudo systemctl status router-watchdog.service
sudo journalctl -u router-watchdog.service -f
sudo systemctl restart router-watchdog.service- Watchdog CSV:
LOG_CSV_PATH(manual default:router_watchdog_events.csv; systemd example:/var/log/router_watchdog_events.csv) - If
LOG_CSV_PATHis not writable, watchdog falls back to: current working directory, then script directory, then/tmp. - Benchmark CSV: configurable via
--csv