Add Raspberry Pi health monitoring

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-09 19:57:07 -04:00
co-authored by Copilot
parent d3bc313e7f
commit 8b664667e5
8 changed files with 355 additions and 70 deletions
+27 -7
View File
@@ -981,13 +981,33 @@ high-water mark plus the latest trip rather than loading the unbounded full hist
markers, DTCs, and video data untouched. The deployed motion-aware logger then proved two
consecutive stationary heartbeats were 60.02 seconds apart rather than five seconds.
### Phase 19: Pi health monitoring card — 🚧 PLANNED
**New phase, small and standalone - no dependencies.** CPU temperature, free disk space, uptime,
and RAM usage are all cheap to read (`vcgencmd measure_temp`, `psutil`/`/proc` stats) and cheap to
display, but currently invisible - the only way to notice a problem (thermal throttling in a hot
car, an SD card filling up) today is to SSH in and check manually. Add a small backend endpoint
and a dashboard card (built on the Phase 15 component set) surfacing these at a glance. Also
feeds directly into Phase 20's alerting.
### Phase 19: Pi health monitoring card — ✅ DONE
Added a dependency-free `/api/health` endpoint and responsive dashboard card reporting CPU
temperature, usable disk pressure/free bytes, RAM usage, human-readable uptime, and Raspberry Pi
firmware power/throttling flags. Data comes from thermal sysfs, `/proc`, `shutil.disk_usage`, and
`vcgencmd get_throttled`; individual unavailable sources are reported explicitly without hiding
the remaining readings. The endpoint exposes structured current and historical flags for Phase
20 alerts, plus warning/degraded/ok status. The browser refreshes every 30 seconds.
**Implemented and verified 2026-08-09:**
- Five focused tests cover memory parsing, missing memory fields, current/historical throttling
bits, malformed firmware output, and ext4 reserved-block-aware disk pressure. Local non-Pi
validation correctly reports thermal/firmware sources as unavailable while retaining disk,
memory, and uptime instead of failing the endpoint.
- Removed the old browser-triggered thread that emitted uptime once per second indefinitely; the
health poll now provides uptime cheaply with the rest of the system snapshot.
- Deployed uncommitted code to the real Pi. The API returned complete data with no source errors:
about 47-49°C, 19-20% RAM, 59% usable disk pressure with 22.8GB free, and roughly two hours
uptime during testing. SQLite/app service behavior remained active.
- Real hardware monitoring immediately found an actionable condition: `vcgencmd get_throttled`
alternated between `0x50005` (current undervoltage and CPU throttling, both previously occurred)
and `0x50000` (historical occurrences after the current condition cleared). The dashboard
prominently distinguishes current warnings from prior events. The Pi power source/cable should
be corrected before sustained in-car use.
- Browser-tested the real dashboard through `http://yaris.local/` at 390x844 and 1280x900:
all four metrics, warning state, timestamp, responsive columns, and 30-second data path rendered
without overflow or new console errors. Also fixed disconnected OBD speed showing `undefined`
and deferred offline map tiles until a real GPS fix, avoiding irrelevant placeholder requests.
### Phase 20: Alerts/notifications — 🚧 PLANNED
**New phase - depends on Phases 13/17/19 existing first**, since it needs real data sources to