Skip to content

JadenJSJ/routerrecuscitator

Repository files navigation

AN5506-04-F Router Recuscitator

Auto-reboot tooling for unstable home routers that freeze and need manual restarts.

Tested device

This setup worked on the following device:

  • Software Version: RP2656
  • Hardware Version: WKF2.134.285F4G
  • Device Model: AN5506-04-F (Fiberhome)
  • Device Description: GPON

What is included

  • router_reboot.py
    Replays router login + reboot flow (/goform/webLogin then /goform/reboot).

  • router_reboot_benchmark.py
    Runs repeated reboot timing tests and records milestone timings to CSV.

  • router_watchdog.py
    Long-running watchdog that:

    1. waits until internet has been working,
    2. triggers recovery only when 1.1.1.1 fails for 30s straight (configurable),
    3. requests a router reboot,
    4. waits forever for eth0 link down/up transition,
    5. retries 1.1.1.1 for 50s with backoff,
    6. if still down, reboots again and repeats,
    7. logs every attempt + outage duration to CSV,
    8. optionally posts Discord embeds (started/outage/diagnostics/stopped).

Files

  • router_reboot.py
  • router_reboot_benchmark.py
  • router_watchdog.py
  • install.sh
  • systemd/router-watchdog.service
  • systemd/router-watchdog.env.example

Environment setup

Create a local env file (for manual runs):

cp .env.example .env

Then 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.env

Manual usage

Single reboot:

python3 router_reboot.py --router 192.168.1.1 --username admin --password admin --verbose

3x benchmark:

python3 router_reboot_benchmark.py --iterations 3 --interface eth0 --csv reboot_timings.csv

Watchdog (manual):

python3 router_watchdog.py

Webhook test only (no monitoring loop):

python3 router_watchdog.py --test-webhook

Simulated outage/reboot flow webhook test (includes multiple reboot attempts before recovery):

python3 router_watchdog.py --test-webhook-flow --test-webhook-reboots 3

All webhook types test (sends one example of every embed type):

python3 router_watchdog.py --test-webhook-all

Discord webhook behavior

Webhook URL can be passed via --discord-webhook or DISCORD_WEBHOOK_URL.

During real outage recovery, when internet stays down after a reboot, the watchdog:

  1. writes a CSV row with state ping_recovery_timeout_rebooting_again,
  2. sends a 🔄 Router Reboot Diagnostics webhook with reboot_status=recovery_timeout,
  3. 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 Test embed
  • --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).

systemd service

Install:

REPO_PATH=/absolute/path/to/routerrecuscitator
sudo "$REPO_PATH"/install.sh

Update (run again from a newer checkout):

REPO_PATH=/absolute/path/to/routerrecuscitator
sudo "$REPO_PATH"/install.sh

Manual 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.service

Manage:

sudo systemctl status router-watchdog.service
sudo journalctl -u router-watchdog.service -f
sudo systemctl restart router-watchdog.service

Logs

  • Watchdog CSV: LOG_CSV_PATH (manual default: router_watchdog_events.csv; systemd example: /var/log/router_watchdog_events.csv)
  • If LOG_CSV_PATH is not writable, watchdog falls back to: current working directory, then script directory, then /tmp.
  • Benchmark CSV: configurable via --csv

About

Auto restart router when internet not working, complete with logging, Discord alerts, and systemd support.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors