Restart modem button: silence Gandalf and Uptime Kuma, restart, end both
Lint / Python (flake8) (push) Failing after 15s
Lint / JS (eslint) (push) Successful in 1m43s
Lint / Deploy (push) Skipped
Test / Python Tests (pytest) (push) Failing after 21s
Security / Python Security (bandit) (push) Successful in 2m3s
Lint / Python (flake8) (pull_request) Failing after 15s
Lint / JS (eslint) (pull_request) Failing after 15s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 2m17s
Lint / Notify on failure (push) Successful in 3s
Test / Python Tests (pytest) (pull_request) Successful in 2m58s

Admins get a Restart modem button on the WAN / Fiber panel (needs
modem.access_code). After a confirmation it:

1. switches an Uptime Kuma maintenance window on (new kuma.py: logs in
   over Kuma 2's Socket.IO API and resumes/pauses one pre-made manual
   window, uptime_kuma.maintenance_id); if Kuma fails it stops and asks
   whether to go on without it,
2. starts Gandalf maintenance (global suppression, 20 minutes at most),
3. posts the gateway's Restart Device form (ModemAdmin.restart), undoing
   1 and 2 if that fails.

The monitor waits for the modem to answer with its WAN up and an uptime
showing it restarted, then switches Kuma off, ends the suppression and
records how long it took; after 30 minutes it ends both regardless. The
panel shows the restart in progress and the result for an hour.

New dependency: python-socketio[client].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-19 19:27:25 -05:00
1 parent f097e4882c
commit c2ff072eb2
13 files changed
+488 -10

No files matched your search

+13 -1
View File
@@ -532,6 +532,16 @@ for read-only checks, stored in `monitor_state.modem_checks`:
- **The gateway's own speed tests** (AT&T runs them from the modem), read with the NAT check; the latest
down and up results are shown on the panel as a reference for what the line itself delivers.
**Restart modem** (admins, WAN / Fiber panel, needs `modem.access_code`): after a confirmation it
1. switches the `uptime_kuma` maintenance window on (if that fails it stops and asks whether to go on
without it),
2. starts Gandalf maintenance (a global suppression for up to 20 minutes, shown in the banner),
3. posts the gateway's Restart Device form. If that fails, steps 1 and 2 are undone.
The monitor then waits for the gateway to answer with its WAN up and an uptime showing it restarted
(at least 3 minutes later), switches the Kuma window off, ends the suppression, and records how long it
took (`monitor_state.modem_restart`). After 30 minutes it ends both regardless. One restart at a time.
The login posts md5(access code + nonce), as the gateway's own page does, so the code itself is never sent.
The session is kept between checks and renewed when it expires. A refused code is reported in Needs
attention and not tried again for 30 minutes, and any other failure pauses the checks for 10 minutes, so
@@ -680,6 +690,7 @@ Shared by both processes. Located in the working directory (`/var/www/html/prod/
| `modem.failure_threshold` | Consecutive failures before ticketing a modem alert (default: same as `failure_threshold`). Raise it if gateway reboots or automatic firmware updates cut tickets. |
| `modem.rx_drift_db` | Rx drop below the 7-day median that raises `fiber_rx_drift` (default: 3.0) |
| `modem.rx_drift_min_samples` | Readings required before drift alerts start (default: 288) |
| `uptime_kuma.url`, `.username`, `.password`, `.maintenance_id` | Optional. Lets the Restart modem button switch an Uptime Kuma maintenance window on and off (Kuma 2.x, over its Socket.IO login). Create the window once in Kuma with the *manual* strategy and the monitors a modem restart takes down, pause it, and put its id here. The account must not use two-factor login. |
| `modem.access_code` | Optional. The gateway's Device Access Code (printed on its label). With it, Gandalf logs in to read NAT session counts and to ping from the gateway when the internet is slow (see WAN modem notes). Keep it only in `config.json`, which is git-ignored and mode 600. |
---
@@ -865,7 +876,8 @@ curl http://10.10.10.48:9090/api/v1/query?query=up | jq '.data.result[] | select
gandalf/
├── app.py # Flask web app (routes, auth, API endpoints)
├── monitor.py # Background daemon (Prometheus, UniFi, Pulse, alert logic)
├── modem.py # AT&T gateway client: status pages, plus optional logged-in NAT and ping checks
├── kuma.py # Switches one Uptime Kuma maintenance window on/off (Restart modem)
├── modem.py # AT&T gateway client: status pages, plus optional logged-in checks and restart
├── devices.py # Device inventory for search and device pages
├── topology.py # The topology graph: devices, cables, depth, last-seen links
├── cutsheet.py # Cutsheet validation, path tracing, plan-vs-actual checks, CSV