Probes log locally only while the hub is unreachable; the hub confirms silences with that log

Probe: no access log, nothing written while reports get through. When the hub
can't be reached, failed reports go to data/outage.jsonl and unsent results to
data/backlog.jsonl (survives restarts). The first report that gets through
uploads both and they are deleted.

Hub: a probe that misses reports gets a "Not reporting" incident. When it
reports again, the runs from its outage log become confirmed "Hub unreachable"
incidents; the rest of the silence (probe off or restarting) is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-04 20:50:30 -08:00
parent 462525b1e2
commit be727949c1
13 changed files with 449 additions and 32 deletions

View file

@ -14,7 +14,12 @@ A home network monitor with two roles, built from one repo:
2. POSTs the results plus its ARP neighbors to the hub's `/api/probe/report` with a per-probe bearer token
3. receives its config (peers, targets) back in the response; that's the only control channel
While the hub is unreachable, results queue in memory and upload later. With no `HUB_URL` it is serve-only, e.g. on a VPS.
While reports get through, the probe writes nothing to disk except `data/probe-config.json` when its config changes (uvicorn's access log is off). While the hub can't be reached (no connection, timeout, 5xx), it writes a local outage log, `app/probe/outage.py`:
- `data/outage.jsonl`: one line per failed report
- `data/backlog.jsonl`: the unsent measurements, so a restart doesn't lose them
The first report that gets through uploads the backlog and sends the failures as runs (`outages` in the report body), then both files are deleted. With no `HUB_URL` it is serve-only, e.g. on a VPS.
- **Probe silences** (`app/hub/outages.py`, table `probe_outages`): when a probe misses reports for `3 × interval + 10` s, the hub opens an unconfirmed "Not reporting" incident. When the probe reports again, its outage runs replace that incident as confirmed "Hub unreachable" incidents; any part of the silence the log doesn't cover (the probe was off or restarting) is dropped. Probes older than this change send no runs, so their silences are always dropped: update them.
Remote: `https://git.neilbantoc.dev/services/network-monitor.git` (Gitea). The repo is public, so anonymous clone and fetch work and installs need no token.
@ -61,12 +66,14 @@ app/main.py picks the hub or probe app by ROLE; shared lifespan (crea
app/hub/server.py FastAPI app, optional UI_PASSWORD basic auth, SPA fallback, /api/info
app/hub/probes.py probe CRUD + POST /api/probe/report (token auth) → returns probe config
app/hub/health.py matrix / strips / incidents / series from the measurements table
app/hub/outages.py probe silences: open "not reporting" incidents, settle them with the probe's outage log
app/hub/dns.py clients, query log, domains, blocked; background AdGuard discovery (60 s)
app/hub/devices.py device merge logic (MAC key, ip: fallback, IP→MAC folding)
app/hub/adguard.py AdGuard client (httpx; tests swap TRANSPORT), query log paging, base_domain
app/hub/settings.py all hub settings from env, read per call
app/hub/db.py SQLite schema (idempotent), one connection per unit of work
app/probe/server.py probe app: /probe/ping, /probe/blob, / (status JSON), the report loop
app/probe/outage.py the probe's local outage log (written only while the hub can't be reached)
app/probe/checks.py icmp (icmplib, unprivileged), http, dns (hand-built UDP query), throughput,
gateway + ARP (Linux /proc/net, macOS route/arp)
app/static/ no-build frontend: house.css/ui.js/shell.js (vendored house style, don't