Modem access code: NAT sessions, and a ping from the modem when slow
Lint / JS (eslint) (push) Successful in 1m11s
Lint / Python (flake8) (push) Successful in 1m55s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 54s
Lint / Python (flake8) (pull_request) Successful in 53s
Test / Python Tests (pytest) (push) Successful in 1m5s
Lint / JS (eslint) (pull_request) Successful in 11s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 55s
Test / Python Tests (pytest) (pull_request) Successful in 1m3s
Lint / JS (eslint) (push) Successful in 1m11s
Lint / Python (flake8) (push) Successful in 1m55s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 54s
Lint / Python (flake8) (pull_request) Successful in 53s
Test / Python Tests (pytest) (push) Successful in 1m5s
Lint / JS (eslint) (pull_request) Successful in 11s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 55s
Test / Python Tests (pytest) (pull_request) Successful in 1m3s
With modem.access_code in config.json, the monitor logs in to the BGW320 (md5 of code + nonce, as its own page does) for two read-only checks, stored in monitor_state.modem_checks: - NAT sessions in use every 30 minutes; Needs attention warns at 80%. - While UniFi says the internet is slow, a ping from the modem itself to 1.1.1.1 (at most every 10 minutes). Compared with UniFi's latency through the modem, it says whether the delay is past the modem (the provider), in the modem, or gone. The Internet line in Needs attention and the WAN / Fiber panel show the result. A refused code is reported and not retried for 30 minutes; other failures pause the checks for 10. The unauthenticated status polling is unchanged. Tested against the real gateway and a fake one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f4cb05f67
commit
de75f71bf8
10 files changed
+645
-8
No files matched your search
@@ -511,6 +511,22 @@ periods had loss or downtime, *high latency* (amber) when 3 or more had any prob
|
||||
the last hour. These are dashboard lines, not tickets, and they go once the hour is clean. A copy older
|
||||
than 30 minutes is ignored.
|
||||
|
||||
**With `modem.access_code` set**, the monitor also logs in to the gateway (`ModemAdmin` in `modem.py`)
|
||||
for two read-only checks, stored in `monitor_state.modem_checks`:
|
||||
- **NAT sessions** every 30 minutes, from the NAT Table page. Needs attention warns when 80% of the
|
||||
gateway's sessions (32,767 on a BGW320) are in use, since new connections stall once it is full.
|
||||
- **A ping from the gateway itself** to 1.1.1.1, from the Troubleshoot page, whenever UniFi flags the
|
||||
current 5 minutes as slow or measures 150 ms or more (at most every 10 minutes). Compared with UniFi's
|
||||
latency through the gateway at the same time, it says where the delay is: *past the modem* (its own
|
||||
ping is slow too, so the provider), *in the modem* (its ping is fine but ours through it is slow), or
|
||||
*fine by then*. The result goes in the detail of the Internet line in Needs attention and on the
|
||||
WAN / Fiber panel.
|
||||
|
||||
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
|
||||
the gateway is never retried in a loop. The status polling above doesn't log in and is unaffected.
|
||||
|
||||
**One ticket per incident.** The modem and WAN reports from one check cycle open a single ticket, led by
|
||||
the most urgent (a P2 "WAN modem unreachable" leads, and an RPDU power-cycle seen in the same cycle is listed
|
||||
under "Also seen in this incident"). A report that comes while the modem has an open alert, or one that
|
||||
@@ -654,6 +670,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) |
|
||||
| `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. |
|
||||
|
||||
---
|
||||
|
||||
@@ -838,7 +855,7 @@ 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 # Read-only AT&T gateway status page client and parser
|
||||
├── modem.py # AT&T gateway client: status pages, plus optional logged-in NAT and ping checks
|
||||
├── 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
|
||||
@@ -920,7 +937,7 @@ Take LED colors from the model's quick start guide. See the comment at the top o
|
||||
`recovery_notified` once the recovery note is on its ticket (column added automatically at monitor startup)
|
||||
- `suppression_rules`: `active=FALSE` when removed; `expires_at` checked at query time
|
||||
- `monitor_state`: key/value store; `interface_baseline`, `link_stats`, and `modem_stats` are JSON blobs
|
||||
- `monitor_state` also holds `wan_history` (WAN outages, modem restarts), `wan_quality` (UniFi's 5 minute WAN health timeline) and `unifi_log_cursor` (how far the UniFi log has been read)
|
||||
- `monitor_state` also holds `wan_history` (WAN outages, modem restarts), `wan_quality` (UniFi's 5 minute WAN health timeline), `modem_checks` (NAT sessions and the latest ping from the gateway) and `unifi_log_cursor` (how far the UniFi log has been read)
|
||||
- Database sessions run in UTC (`db.py`), whatever the server's time zone
|
||||
- `modem_samples`: optical readings per poll, kept 90 days; created automatically at monitor startup
|
||||
- `cutsheet_items`, `cutsheet_cables`, `cutsheet_port_labels`, `cutsheet_history`: cutsheet records and
|
||||
@@ -976,7 +993,7 @@ Branch protection is enabled on `main`: both lint jobs must pass before any PR c
|
||||
Tests live in `tests/`:
|
||||
- `test_diagnose.py`: `DiagnosticsRunner` static methods (`build_ssh_command`, `parse_output`,
|
||||
`parse_sysfs_stats`, `parse_ethtool`, and variants)
|
||||
- `test_modem.py`: gateway page parsing, optical status, and WAN state
|
||||
- `test_modem.py`: gateway page parsing, optical status, WAN state, and the logged-in checks against a fake gateway
|
||||
- `test_monitor.py`: alert logic for dead hosts, Prometheus and Pulse outages, and modem and WAN log events
|
||||
- `test_devices.py`: device inventory behind search and device pages
|
||||
- `test_app.py`: page and API routes
|
||||
Reference in new issue
Block a user