Long-term telemetry: hourly rollups in JSONL, a range selector in the UI

- telemetry/record.py: a Recorder subscribed to Telemetry keeps min/avg/max
  per metric for the current hour and appends each finished hour as one JSON
  line to records-YYYY-MM.jsonl in the data dir (~400 days kept; whole months
  older than that are pruned on start). Best effort by design: a failing disk
  logs once and stops recording; nothing else notices. load() merges lines per
  hour (a restart re-writes the current hour; torn last lines are skipped).
- app.py: the recorder runs unless --demo (simulated samples must not mix into
  real records) and flushes the open hour in close(), after the telemetry
  thread has stopped. records(days) validates 1..400.
- Web: GET /api/records?days=N (bad values answer 400 with the reason).
- UI: a range selector above the power/temperature charts switches them
  between the live 10 minutes and hourly averages for 24 h / 7 d / 30 d /
  1 y; the chart window, tick labels (min/h/d), tooltips and table captions
  adapt to the span. Live samples keep accumulating behind a long-range view,
  so switching back is instant.
- Tests: test_record.py (5) and a /api/records case in test_web.py; README
  updated (API table, System section, layout).
This commit is contained in:
paul committed 2026-12-05 18:04:57 +13:00
1 parent ba39016d52
commit f717f7a82f
8 files changed
+371 -18

No files matched your search

+9 -3
View File
@@ -1,5 +1,7 @@
# The Kurgan
![The Kurgan's sword](kurgan/assets/sword.png)
One process that runs this PC's backend systems, with one web UI at **<http://127.0.0.1:8080/>**:
| Capability | What it does | Package |
@@ -55,7 +57,7 @@ icon also pops a balloon tip when something starts to go wrong — a fan group e
an AI server reporting an error, or a sensor source starting to fail. What is already wrong when
The Kurgan starts is not ballooned; it sits in the tray menu and the UI.
- **System**: CPU and GPU temperature, load, clock and power; GPU memory; the LCD's state. Charts show whole-PC power (stacked: other, CPU, GPU) and temperatures over the last 10 minutes. When a sensor source's last read failed — a disconnected Commander PRO, a busy NVML — a pill in the header names it and hover shows the error.
- **System**: CPU and GPU temperature, load, clock and power; GPU memory; the LCD's state. Charts show whole-PC power (stacked: other, CPU, GPU) and temperatures over the last 10 minutes. A range selector above the charts switches them to hourly averages for 24 hours, 7 days, 30 days or a year. Those long-term rollups live in `%LOCALAPPDATA%\Kurgan\records-YYYY-MM.jsonl` — one JSON line per hour, about 400 days kept, written best effort (a failing disk stops recording and nothing else notices; `--demo` never records). When a sensor source's last read failed — a disconnected Commander PRO, a busy NVML — a pill in the header names it and hover shows the error.
- **Cooling**: the fan profile selector; each fan group's duty, temperature and RPMs; fan speeds over time; and the selected profile's curves, with a dot for each group's current operating point. Hover over a profile to preview its curves.
- **Lighting**: a mode selector per zone (case fans, RAM, GPU), the zone's status, and the shared chase speed.
- **AI**: pick Strata (and its model), llama.cpp or None; requests to either address also pick it. Then see the server's process, model, context size, live request progress and token speeds, and when it will stop if unused; load or unload the model; GPU memory over time; and recent requests.
@@ -69,6 +71,7 @@ next start.
| --- | --- |
| `GET /api/state` | Everything live (what the UI polls), including `telemetry.health`: the sensor sources whose latest read failed, each with its error and age |
| `GET /api/history` | The last 10 minutes of telemetry and fan duty |
| `GET /api/records?days=N` | Hourly min/avg/max rollups for the last N days (1-400), oldest first |
| `GET /api/config` | Fan profiles and LCD theme thresholds |
| `POST /api/lighting` | `{"zone": "case_fans"\|"memory"\|"gpu", "mode": "off"\|"temperature"\|"chase"}` |
| `POST /api/cooling/profile` | `{"profile": "quiet"\|"balanced"\|"performance"\|"full"}` |
@@ -378,13 +381,16 @@ kurgan/
app.py wires the capabilities together; command line; single instance
settings.py settings.json: defaults, strict validation, atomic saves, legacy import
paths.py, theme.py, tray.py, demo.py (simulated hardware for --demo)
telemetry/ sensors.py (CPU/GPU/system power), readings.py, service.py (sampling + history)
telemetry/ sensors.py (CPU/GPU/system power), readings.py, service.py (sampling + history),
record.py (hourly rollups for the long-term charts)
display/ tt_lcd.py (panel HID protocol), renderer.py, service.py (LCD loop), background.png
cooling/ profiles.py, control.py (case-fan groups, top-fan curve), board_fans.py (NCT6687D)
lighting/ case_fans.py (CORE patterns + shared chase clock), lighting_node.py, memory.py, gpu.py, service.py
ai/ config.py, launcher.py (non-elevated child processes in job objects),
backends.py (Strata, llama.cpp), service.py (one-at-a-time supervisor), strata_host.py
web/ server.py (API), static/ (index.html, app.js, style.css)
web/ server.py (API), static/ (index.html, app.js, style.css, logo.png, favicon.ico)
assets/ sword.png, hilt.png, kurgan.ico (tray icon); make_assets.py rebuilds them and the
web UI's logo and favicon from The-Kurgan-Sword.png
hardware/ hid.py (Windows HID), pawnio/ (signed PawnIO modules, LGPL-2.1)
tests/ unittest suites
docs/ design references and research notes