mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 18:47:42 +01:00
Four fixes to the box's self-monitoring, all root-caused rather than papered over. **The 40-alert storm** was a shell return-code trap, not an incident: `alert_transition` ended with `[ test ] && cmd`, exporting the test's result as the function's return code, so `cmd && A || B` ran the recovery branch after a *successful* alert. Every tick emitted DISK + RECOVERED and the state file never advanced. Now returns 0 unconditionally, with hysteresis (bad >85%, ok <80%) so the disk can't flap. **The memory check could never fire** — `read` binds all trailing fields to the last variable, so the parsed values were garbage. Dead since it was written. Rewritten with awk against the real `free -m` field layout. **The disk keeps filling** because of dev checkouts, not apps: ~13 repos under `/home/ubuntu/dev` × ~1GB node_modules ≈ 12GB, growing ~1GB per repo added. All deployed apps together are 190MB. New hourly `disk-gc` no-ops below 80% and reclaims to 70% in cost order (caches → npm → releases beyond 2 → node_modules of repos idle ≥14d, coldest first), skipping anything with a live process and refusing paths outside its root. Freed 3.8GB on first run; box 86% → 76%. **Hetzner upgrade capacity is now visible.** The poller was already alerting on Telegram but wrote nothing anyone could see; it now emits state that `/system` renders as a Box capacity card. Every spec comes from the Hetzner API — bitbaum is a cx33 (4/8/80); cx43 doubles the disk to 160GB and is the real fix for the disk problem. 33 shell tests cover the logic that ships in the heredocs (extracted from the payload, not a drifting copy), wired into `verify` via `npm run test:ops`.