Personal monitoring tool for my linux setup. Think of a simplified version of Grafana + Prometheus but fully local.
Metric collectors (Zig)
main.zig → ticker loop (1s aligned)
cpu.zig → reads /proc/stat → POST /api/metrics/cpu
memory.zig → reads /proc/meminfo → POST /api/metrics/memory
temperature.zig → reads /sys/class/thermal → POST /api/metrics/temperature
battery.zig → reads /sys/class/power_supply/BAT0/capacity → POST /api/metrics/battery
│
│ POST JSON every 1s
▼
Bun HTTP server (service/index.ts) :2697
│
├── INSERT INTO SQLite (metrics.db)
│
└── broadcast via WebSocket (/ws)
│
▼
Web dashboard (web/index.html) at /web
- CPU area chart
- Memory spline-area chart
- Temperature spline-area chart
- Battery column chart (color-coded by level)
| Layer | Tech | Role |
|---|---|---|
| Collector | Zig | Reads Linux /proc and /sys pseudofiles, POSTs metrics every 1s |
| API | Bun + TypeScript | HTTP + WebSocket server, persists metrics to SQLite |
| Storage | SQLite (WAL mode) | Time-series storage, auto-purges data older than 1 day |
| Dashboard | HTML + CanvasJS | Real-time charts over WebSocket |
- CPU usage — percentage calculated from
/proc/stat(stateful delta across ticks, sampled once per 1s tick) - Memory usage — percentage from
MemTotal/MemAvailablein/proc/meminfo - Temperature — CPU thermal zone in °C from
/sys/class/thermal/thermal_zone0/temp - Battery — charge percentage from
/sys/class/power_supply/BAT0/capacity
| Method | Route | Description |
|---|---|---|
POST |
/api/metrics/cpu |
Ingest CPU usage |
POST |
/api/metrics/memory |
Ingest memory usage |
POST |
/api/metrics/temperature |
Ingest temperature |
POST |
/api/metrics/battery |
Ingest battery level |
GET |
/api/history?metric=<name> |
Last 200 data points for a metric |
WS |
/ws |
Real-time broadcast of all incoming metrics |
GET |
/web |
Web dashboard |
- Install service dependencies:
cd service && bun install- Start everything from the project root:
bash ./script.shThis starts the Bun API server, then waits for it to be ready before launching the Zig collector process (which runs all four collectors on a 1s tick via main.zig).
- Open the dashboard at
http://localhost:2697/web