Internet health from UniFi: Needs attention line and a 24 hour strip #46

Merged
jared merged 1 commits from wan-health into main 2026-11-16 13:12:32 -05:00
Owner

Why

The internet was slow and lossy on and off for about a day, and Gandalf showed nothing: it only notices the WAN being fully down. UniFi already rates the WAN every 5 minutes (fine, high latency, packet loss, down), the same timeline its Network app charts. So Gandalf reads that instead of pinging on its own.

What

  • Monitor: each cycle reads the last day from UniFi's dashboard API (v2/.../aggregated-dashboard, read only) and stores monitor_state.wan_quality: 5 minute periods, drops, and current latency to Cloudflare, Google and Microsoft. If UniFi can't be read, the last copy stays and is ignored once it's 30 minutes old.
  • Needs attention (Broken now), judged on the newest 12 periods:
    • Internet: packet loss in N of the last 12 five-minute periods: red when 2 or more had loss or downtime.
    • Internet: high latency in N of the last 12 ...: amber when 3 or more had any problem.
    • Internet dropped for 90 s, 20 min ago (or "dropped N times in the last hour").
    • The detail gives the 24 hour count and the latency now. These are dashboard lines only, not tickets, and they clear once the hour is clean.
  • WAN / Fiber panel: a 24 hour strip (amber latency, red loss, white or black down) with hover times, a legend and latency now. It also shows while the modem's own page can't be read.

Run against today's real UniFi data, it gives 104 high-latency, 11 packet-loss and 1 down periods out of 296. The list currently shows "packet loss in 6 of the last 12" and "dropped for 90 s, 20 min ago".

Screenshots

The preview uses today's real timeline (states only) and documentation addresses.

Needs attention:
attention

WAN / Fiber panel, dark:
dark

Light:
light

Phone:

Checks

  • 524 tests pass (new: TestWanQuality, TestWan, TestWanQualityCollection, and an app test that the stored timeline reaches /api/attention and /api/modem).
  • flake8 and bandit are clean; eslint is at the 21-warning baseline.
  • No horizontal scroll at 390 px.

🤖 Generated with Claude Code

## Why The internet was slow and lossy on and off for about a day, and Gandalf showed nothing: it only notices the WAN being fully down. UniFi already rates the WAN every 5 minutes (fine, high latency, packet loss, down), the same timeline its Network app charts. So Gandalf reads that instead of pinging on its own. ## What - **Monitor**: each cycle reads the last day from UniFi's dashboard API (`v2/.../aggregated-dashboard`, read only) and stores `monitor_state.wan_quality`: 5 minute periods, drops, and current latency to Cloudflare, Google and Microsoft. If UniFi can't be read, the last copy stays and is ignored once it's 30 minutes old. - **Needs attention** (Broken now), judged on the newest 12 periods: - *Internet: packet loss in N of the last 12 five-minute periods*: red when 2 or more had loss or downtime. - *Internet: high latency in N of the last 12 ...*: amber when 3 or more had any problem. - *Internet dropped for 90 s, 20 min ago* (or "dropped N times in the last hour"). - The detail gives the 24 hour count and the latency now. These are dashboard lines only, not tickets, and they clear once the hour is clean. - **WAN / Fiber panel**: a 24 hour strip (amber latency, red loss, white or black down) with hover times, a legend and latency now. It also shows while the modem's own page can't be read. Run against today's real UniFi data, it gives 104 high-latency, 11 packet-loss and 1 down periods out of 296. The list currently shows "packet loss in 6 of the last 12" and "dropped for 90 s, 20 min ago". ## Screenshots The preview uses today's real timeline (states only) and documentation addresses. Needs attention: ![attention](https://code.lotusguild.org/LotusGuild/gandalf/raw/branch/pr-46-screenshots/wan-att-dark.png) WAN / Fiber panel, dark: ![dark](https://code.lotusguild.org/LotusGuild/gandalf/raw/branch/pr-46-screenshots/wan-modem-dark.png) Light: ![light](https://code.lotusguild.org/LotusGuild/gandalf/raw/branch/pr-46-screenshots/wan-modem-light.png) Phone: <img src="https://code.lotusguild.org/LotusGuild/gandalf/raw/branch/pr-46-screenshots/wan-modem-phone.png" width="390"> ## Checks - 524 tests pass (new: `TestWanQuality`, `TestWan`, `TestWanQualityCollection`, and an app test that the stored timeline reaches `/api/attention` and `/api/modem`). - flake8 and bandit are clean; eslint is at the 21-warning baseline. - No horizontal scroll at 390 px. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-11-16 12:38:56 -05:00
Internet health from UniFi: Needs attention line and a 24 hour strip
Lint / JS (eslint) (push) Successful in 1m10s
Lint / Python (flake8) (push) Successful in 2m31s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m26s
Lint / Python (flake8) (pull_request) Successful in 1m4s
Test / Python Tests (pytest) (push) Successful in 1m13s
Lint / JS (eslint) (pull_request) Successful in 7s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m0s
Test / Python Tests (pytest) (pull_request) Successful in 1m3s
6a717af3f2
UniFi already rates the WAN every 5 minutes (fine, high latency, packet
loss, down), the same timeline its Network app charts. The monitor now
reads the last day of it from the dashboard API each cycle, read only,
instead of Gandalf pinging on its own.

- modem.wan_quality() turns the dashboard data into periods, drops and
  current service latencies; stored as monitor_state.wan_quality.
- Needs attention: "Internet: packet loss in N of the last 12 five-minute
  periods" (2+ lossy periods, red), "high latency" (3+ bad periods,
  amber), and drops in the last hour. Stale copies are ignored.
- WAN / Fiber panel: a 24 hour strip with a legend and latency now,
  also shown while the modem itself can't be read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared scheduled this pull request to auto merge when all checks succeed 2026-11-16 13:12:30 -05:00
jared merged commit 73787daaec into main 2026-11-16 13:12:32 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/gandalf#46