Skip to content

ize-302/mini-monitoring-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini monitoring tool

Personal monitoring tool for my linux setup. Think of a simplified version of Grafana + Prometheus but fully local.

system architecture for local monitoring tool

System architecture

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)

Stack

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

Metrics collected

  • CPU usage — percentage calculated from /proc/stat (stateful delta across ticks, sampled once per 1s tick)
  • Memory usage — percentage from MemTotal / MemAvailable in /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

API

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

How to run

  1. Install service dependencies:
cd service && bun install
  1. Start everything from the project root:
bash ./script.sh

This 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).

  1. Open the dashboard at http://localhost:2697/web

About

Personal monitoring tool for my linux setup

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors