added control page
This commit is contained in:
@@ -8,7 +8,8 @@ Three Docker containers sharing a named volume (`speed-logger_sqlite-data`) that
|
||||
|
||||
- **speedtest** (`measurement/`) — Python + cron inside a Debian slim container. Runs measurements and writes results to SQLite.
|
||||
- **ping** — Same image, runs `run_ping.py` as a long-lived loop (not cron) with `network_mode: host` so it can reach the LAN gateway. Pings the gateway plus a rotating pool of external DNS-resolver IPs every `PING_INTERVAL` (5s) and writes to `ping_checks`.
|
||||
- **grafana** — Stock Grafana image with the `frser-sqlite-datasource` plugin. Reads from the shared SQLite volume. Dashboard and datasource are provisioned automatically from `grafana/provisioning/`.
|
||||
- **control** — Same image, runs `control.py`: a stdlib `http.server` page on port 80 (host port `CONTROL_PORT`) where household members toggle speedtests on/off from a phone. Writes the flag to the `settings` table; talks to humans only, never to other containers.
|
||||
- **grafana** — Stock Grafana image with the `frser-sqlite-datasource` plugin. Reads from the shared SQLite volume. Dashboard and datasource are provisioned automatically from `grafana/provisioning/`. Anonymous read-only access is enabled (`GF_AUTH_ANONYMOUS_*`); because any viewer can POST arbitrary SQL to Grafana's datasource query API, the volume is mounted `:ro` and the datasource path uses `?mode=ro`. Do not remove either when touching the compose file. This also means the DB must stay in the default rollback journal mode — WAL would require write access to the directory even for readers.
|
||||
|
||||
No message queues, no ORM, no external services. Everything is plain Python stdlib + subprocess calls.
|
||||
|
||||
@@ -18,8 +19,9 @@ No message queues, no ORM, no external services. Everything is plain Python stdl
|
||||
|---|---|
|
||||
| `measurement/run_speedtest.py` | Entry point. Shells out to `speedtest` CLI, parses JSON result, writes to DB. |
|
||||
| `measurement/run_ping.py` | Long-running loop for the ping container. Detects the default gateway from `/proc/net/route`, pings it plus 3 external IPs per iteration. |
|
||||
| `measurement/control.py` | Control page for the household speedtest toggle. Seeds the `settings` row from `SPEEDTEST_ENABLED` on first start; after that the DB row is the source of truth. |
|
||||
| `measurement/db.py` | SQLite init and insert. All schema lives here. |
|
||||
| `measurement/config.py` | Env vars: `DB_PATH`, `PING_INTERVAL`. |
|
||||
| `measurement/config.py` | Env vars: `DB_PATH`, `PING_INTERVAL`, `SPEEDTEST_ENABLED` (initial toggle state only; the live state is the `speedtest_enabled` row in `settings`). When disabled, the cron job still fires but exits before running the test, and no failed row is written. |
|
||||
| `measurement/crontab` | Cron schedule. Currently `4-59/15` (jittered to avoid running exactly on the quarter-hour, which gave flaky Ookla results). |
|
||||
| `measurement/Dockerfile` | Installs Ookla `speedtest` CLI via packagecloud, sets up cron. |
|
||||
| `grafana/provisioning/` | Auto-provisioned datasource and dashboard JSON. |
|
||||
@@ -49,6 +51,8 @@ id, timestamp (unix float), target_ip, success (bool), latency_ms, is_gateway (i
|
||||
|
||||
`is_gateway=1` rows are pings to the local router; the gateway-vs-external split is what lets the dashboard distinguish "WiFi/router down" from "ISP down".
|
||||
|
||||
`settings` (key-value, currently only `speedtest_enabled` = "0"/"1"): shared state between the control page (writes), the speedtest cron job (reads) and Grafana (displays). This is the only cross-container communication channel besides the measurement tables.
|
||||
|
||||
## Dashboard
|
||||
|
||||
`grafana/provisioning/dashboards/speed_tests.json` (uid `speed-tests-v2`, title "Network Status"). Layout top to bottom: live UP/DOWN stats (last 60s, independent of the time picker via `strftime('%s','now')`), status-page-style state timelines (Internet/Router plus one row per ping-target provider), ping latency, speed tests, ISP SLA checks, hourly/weekday pattern charts, collapsed raw table.
|
||||
|
||||
Reference in New Issue
Block a user