Skip to content
LarsLaskowskiPublic

About

Lightweight system-monitoring dashboard for the Raspberry Pi — CPU, temperature, memory, disk & network metrics, a self-contained web UI, a versioned REST API, and alert webhooks. Single Go binary, no database.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PiMonitor

A lightweight system-monitoring dashboard for the Raspberry Pi. A single Go binary collects system metrics, serves a self-contained web dashboard, and exposes a versioned REST API for third-party integration (e.g. home automation systems like openHAB). Runs as a systemd service.

PiMonitor dashboard

The Console theme, light and dark:

PiMonitor dashboard, Console theme, light PiMonitor dashboard, Console theme, dark

Features

  • CPU usage - overall and per-core percentage, with a trend sparkline
  • CPU frequency & governor (REST API) - per-core clock speed and active cpufreq scaling governor
  • Load average - 1/5/15 minute values shown as gauges, scaled to CPU core count
  • CPU temperature - auto-detected thermal zone, with optional vcgencmd-sourced GPU and PMIC (Pi 4/5) temperatures if available
  • Memory & swap usage
  • Filesystem usage - per mounted filesystem, pseudo filesystems (tmpfs, proc, overlay, ...) always excluded; a filesystem bind-mounted at several places is listed once
  • Disk I/O throughput (REST API) - per block device read/write bytes-per-second
  • Network throughput per interface (optional, can be disabled)
  • System identity - host name, kernel version, OS distribution, Raspberry Pi model
  • Uptime - device clock and time since boot
  • Available apt updates - count and package list, with a staleness indicator for the underlying apt cache, and whether the last check succeeded
  • Pi-hole updates - when a native Pi-hole v6+ is installed, whether Core, Web or FTL have an update, read from Pi-hole's own daily version check
  • openHAB status - when openHAB runs on the same Pi, a card with its process memory, JVM heap, Things by status (the names of those not ONLINE on request), Items, add-ons, version and uptime, read from its REST API on loopback, and a chart of its memory (RSS, JVM heap, restarts) over the last 24 hours (openhab.history_window_hours); hidden when openHAB is not installed
  • Short metric history (default: last 60 minutes) for sparklines, periodically snapshotted to a compact binary file so it survives restarts and reboots - no database
  • Threshold alerts - a server-side engine maps each poll against the configured warn/critical thresholds into per-metric alert states with debounced fired/cleared events, exposed via GET /api/v1/alerts; a local openHAB adds three rules: openhab_down (not running or not reachable), openhab_rss_percent (its memory share of the Pi) and openhab_things_offline (needs an openHAB API token), with 0 turning a threshold off
  • Alert webhooks - optionally POST a JSON payload (with a per-webhook severity filter, custom body template, retry-with-backoff and basic rate-limiting) to one or more HTTP endpoints on each fired/cleared transition, so alerts reach Slack, Discord, Home Assistant, ntfy, etc. Delivery is fully off the collection path, so a slow webhook never blocks metric sampling
  • Light/dark mode toggle - follows the OS setting by default, with a manual override remembered in the browser
  • Choosable themes - Clear and Console (a monospace, outlined look), picked in the Customize dialog, remembered in the browser
  • Configurable dashboard layout - show/hide and reorder metric cards from a settings modal, remembered in the browser
  • A versioned REST API (/api/v1/...) for third-party consumers, with optional API-key authentication and gzip-compressed responses, including per-metric endpoints (/api/v1/metrics/temperature, /memory, ...) for integrations that only poll a single value - see docs/API.md
  • Prometheus /metrics endpoint (optional, off by default) - the current snapshot and the local openHAB status in the Prometheus text exposition format, for scraping straight into Prometheus/Grafana with no extra exporter - see docs/API.md

Architecture

                  ┌─────────────────────────────┐
                  │        pimonitor (Go)       │
                  │                             │
 /proc, /sys ───▶ │  collector  ──▶  httpapi   │───▶ Web dashboard
 apt cache        │  (in-memory          │      │     (embedded assets)
                  │   ring buffers)      ▼      │
                  │      │          /api/v1/... │───▶ Third-party clients
                  │      │ alert events         │        (e.g. openHAB)
                  │      ▼                      │
                  │   notifier ─────────────────│───▶ HTTP webhooks
                  └─────────────────────────────┘   (Slack, ntfy, HA, ...)

 pimonitor.service          pimonitor-apt-update.timer (root)
 runs unprivileged    <--   refreshes apt cache every 6h;
 reads /proc, /sys,         pimonitor itself never needs
 and the apt cache          root privileges
 read-only

The main service (pimonitor.service) never requires root: it only reads world-readable files under /proc, /sys/class/thermal, /sys/devices/system/cpu/*/cpufreq, /sys/class/hwmon, /etc/os-release, /var/lib/dpkg/status, the apt cache, Pi-hole's /etc/pihole/versions, and, for the optional openHAB status, openHAB's install directories, the /proc entries of its process and /proc/net/tcp* (plus loopback HTTP requests to openHAB itself), plus the read-only apt-cache dumpavail command and the optional vcgencmd readings (for which the unit adds the service to the video group, needed to open /dev/vcio_gencmd / /dev/vchiq on Raspberry Pi OS). A separate, root-privileged systemd timer (pimonitor-apt-update.timer) refreshes the apt cache periodically - see SECURITY.md for the full threat model.

Building

Requires Go 1.27+.

make build          # native build, for local development -> bin/pimonitor
make build-arm64     # cross-compile for 64-bit Raspberry Pi OS (Pi 3/4/5)
make build-arm       # cross-compile for 32-bit / Pi Zero/1 (GOARM=6)
make test            # go test ./...
make lint             # golangci-lint (also enforced in CI)

make run starts the server locally against packaging/pimonitor.example.yaml - useful for frontend/API development on a non-Pi machine. Hardware-specific metrics (e.g. CPU temperature) simply report as unavailable rather than failing.

Pre-built binaries for tagged releases are published via GitHub Actions using goreleaser - see the Releases page.

Installing on a Raspberry Pi

1. Download and extract the release

On the Pi, download the release tarball matching your Raspberry Pi OS and extract it. Release assets are named pimonitor_<version>_linux_<arch>.tar.gz, with <arch> being:

  • arm64 - 64-bit Raspberry Pi OS (Pi 3/4/5)
  • armv6 - 32-bit Raspberry Pi OS, or any Pi Zero/1

The snippet below fetches the latest version automatically via the GitHub API, so you only need to set ARCH:

For a reusable variant of the same process, download and run download-latest.sh:

curl -fsSLO https://raw.githubusercontent.com/LarsLaskowski/PiMonitor/main/packaging/download-latest.sh
chmod +x download-latest.sh
./download-latest.sh

The script detects the architecture automatically (aarch64 becomes arm64; 32-bit Raspberry Pi OS becomes armv6), downloads and extracts the latest release, then lists its contents. To override the detection, run it with ARCH=arm64 ./download-latest.sh or ARCH=armv6 ./download-latest.sh.

The script checks the archive against the release's checksums.txt with sha256sum and stops without extracting on a mismatch or a missing entry. This detects a corrupted or incomplete download but does not prove who built the release; the manual commands below do not check the archive at all.

ARCH=arm64   # or armv6, see above

VERSION=$(curl -fsSL https://api.github.com/repos/larslaskowski/pimonitor/releases/latest | grep -m1 '"tag_name"' | cut -d '"' -f4)
wget "https://github.com/larslaskowski/pimonitor/releases/download/${VERSION}/pimonitor_${VERSION#v}_linux_${ARCH}.tar.gz"
tar xzf "pimonitor_${VERSION#v}_linux_${ARCH}.tar.gz"
cd "pimonitor_${VERSION#v}_linux_${ARCH}"

ls
# download-latest.sh  install.sh  pimonitor  pimonitor.service
# pimonitor-apt-update.service  pimonitor-apt-update.timer
# pimonitor.example.yaml  README.md  LICENSE.md

Alternatively, pick a specific version and architecture manually from the Releases page. Either way you get a single pimonitor_<version>_linux_<arch>/ directory containing everything the installer needs — the binary (named plainly pimonitor), install.sh, and the systemd units. Run the remaining steps from inside that directory.

2. (Optional) Customize the configuration before installing

install.sh never overwrites an existing /etc/pimonitor/config.yaml - it only writes one if none exists yet. If you want to start with non-default settings (for example a different listen_addr because port 8080 is already used by something else on the Pi) instead of editing the config and restarting afterwards, stage it yourself before running install.sh:

sudo mkdir -p /etc/pimonitor
sudo cp pimonitor.example.yaml /etc/pimonitor/config.yaml
sudo nano /etc/pimonitor/config.yaml   # e.g. change listen_addr

This matters in particular for listen_addr: if the configured port is already in use, pimonitor.service fails to bind it and keeps crash-looping (Restart=on-failure, retried every 5s) - but install.sh itself reports success and prints no error, because systemctl enable --now returns immediately without waiting to see whether the service actually stays up. Always verify the service is running after installing, see step 4.

3. Run the installer

sudo ./install.sh

Run it from inside the extracted directory (see step 1). The installer picks up the pimonitor binary sitting next to it automatically — no path argument needed.

This creates an unprivileged pimonitor system user, installs the binary to /usr/local/bin/pimonitor, writes a default config to /etc/pimonitor/config.yaml (if one doesn't already exist), installs the three systemd unit files, and enables/starts pimonitor.service and pimonitor-apt-update.timer. Because the config file may contain the api_key secret, the installer keeps it readable only by root and the pimonitor group (/etc/pimonitor is 750 root:pimonitor, the config file 640 root:pimonitor) — re-running install.sh also tightens the permissions of an existing config without touching its content. See packaging/pimonitor.example.yaml for every configuration option.

If you are installing from a source checkout instead of a release archive (so there is no pre-built binary next to the script) and have a Go toolchain installed directly on the Pi, install.sh builds one for you:

sudo ./packaging/install.sh

4. Verify the installation

systemctl status pimonitor.service pimonitor-apt-update.timer
journalctl -u pimonitor -f

A successful install shows active (running) for pimonitor.service. If instead you see activating (auto-restart) or a growing restart count, the process is crash-looping on startup (a busy listen_addr port is the most common cause). Check the actual error with journalctl -u pimonitor -n 50, fix /etc/pimonitor/config.yaml accordingly, then apply it with:

sudo systemctl restart pimonitor.service

The dashboard is then available at http://<pi-address>:8080/ (or whatever port you configured).

Migrating from RPi-Monitor

If you're replacing RPi-Monitor with PiMonitor on the same device, remove RPi-Monitor completely before installing PiMonitor. PiMonitor listens on port 8080 by default, RPi-Monitor's bundled lighttpd on 8888, so the two don't collide as long as you keep the default ports - but if you plan to reuse RPi-Monitor's old port (e.g. set listen_addr to :8888 so existing bookmarks/firewall rules keep working), RPi-Monitor's lighttpd must be stopped first, or pimonitor.service will fail to bind that port and crash-loop on startup (see step 4 of the installation instructions above). Installing PiMonitor first and cleaning up RPi-Monitor afterwards works too, but only if you're not reusing the port.

The exact paths below assume RPi-Monitor was installed from the .deb package; adjust them if you built it manually. As with any rm -rf, take a backup first if you're unsure and review each command before running it.

1. Stop the service

sudo systemctl stop rpimonitor

Stops the running service so its files aren't locked during removal.

2. Disable the service

sudo systemctl disable rpimonitor

Removes the systemd symlinks so RPi-Monitor no longer starts on boot.

3. Remove the package

sudo apt-get remove --purge rpimonitor

Uninstalls the binaries; --purge also removes the package's own configuration files.

4. Clean up dependencies

sudo apt-get autoremove --purge

Removes libraries that were only pulled in for RPi-Monitor and any orphaned configuration files left behind.

5. Delete leftover files

RPi-Monitor leaves files outside of what apt manages:

sudo rm -rf /etc/rpimonitor/
sudo rm -rf /usr/share/rpimonitor/
sudo rm -rf /var/lib/rpimonitor/
sudo rm -rf /var/log/rpimonitor/
sudo rm -rf /var/www/rpimonitor/   # only if you had a web server integration

6. Remove cron jobs

RPi-Monitor typically schedules its sensor-collection script via cron:

sudo crontab -e

Remove any lines referencing rpimonitor or /usr/share/rpimonitor/scripts/. Also check for a system-wide job and remove it if present:

sudo rm -f /etc/cron.d/rpimonitor

7. Check for leftover systemd unit files

Only relevant if RPi-Monitor was installed manually rather than via apt:

ls /etc/systemd/system/ | grep rpimonitor
sudo rm -f /etc/systemd/system/rpimonitor.service   # if found
sudo systemctl daemon-reload

8. Clean up web server configuration

Only relevant if RPi-Monitor was fronted by Apache or Nginx instead of its bundled lighttpd:

# Apache
sudo rm -f /etc/apache2/conf-available/rpimonitor.conf
sudo a2disconf rpimonitor
sudo systemctl reload apache2

# Nginx
sudo rm -f /etc/nginx/sites-enabled/rpimonitor
sudo systemctl reload nginx

9. Final check

which rpimonitor          # no output
systemctl status rpimonitor   # "Unit rpimonitor.service could not be found."
dpkg -l | grep rpimonitor     # no output

If all three come back clean, RPi-Monitor is fully removed and PiMonitor is the only monitoring service left running on the Pi.

Updating

PiMonitor is distributed as a single binary plus its systemd units. The recommended way to upgrade is to re-run install.sh from the new release: it overwrites the binary and the systemd units, reloads systemd and restarts running units, but leaves an existing /etc/pimonitor/config.yaml untouched.

Replacing only the binary is not enough when a release changes the systemd units. For example, 1.1.0 adds SupplementaryGroups=video to pimonitor.service; without the new unit, the vcgencmd-based readings (throttled, gpu_temperature, pmic_temperature) stay empty on Raspberry Pi OS.

install.sh overwrites /etc/systemd/system/pimonitor.service, so edits made directly in that file are lost on upgrade. Keep local customisations in a drop-in instead (sudo systemctl edit pimonitor.service, stored under pimonitor.service.d/), which install.sh leaves alone. Only if you install the units by hand do you need to merge the changes from packaging/pimonitor.service yourself.

Upgrading to 1.3.0 on a Pi that runs openHAB. openhab.enabled defaults to auto, so after the upgrade PiMonitor finds a local openHAB on its own: the dashboard shows the openHAB card, GET /api/v1/openhab and, with prometheus_enabled: true, the /metrics endpoint report it, and, with alerts on (the default), the rules openhab_down and openhab_rss_percent are evaluated, and openhab_things_offline too once an openHAB API token is configured. Their events reach your webhooks with these new metric values, so check a receiver or body template that expects only the older metrics. Set openhab.enabled: false to keep the previous behavior; a 0 turns a single openHAB threshold off (see docs/integrations/openhab.md). The pimonitor.service changes of 1.3.0 are comments only. A history.bin written by 1.3.0 still loads in 1.2.0, which drops only the openHAB series.

  1. Get the new version. Either download the binary (or release tarball) for your architecture from the Releases page, or pull the latest source and cross-compile it (make build-arm64 / make build-arm).

  2. Re-run the installer from inside the newly extracted release directory:

    sudo ./install.sh

    This replaces /usr/local/bin/pimonitor, refreshes the systemd units, runs systemctl daemon-reload, and restarts pimonitor.service and pimonitor-apt-update.timer if they were already running, so the new binary and units take effect immediately. Your configuration is preserved.

  3. Restart manually only if you did not use install.sh (e.g. you copied the binary and unit files yourself):

    sudo systemctl daemon-reload
    sudo systemctl restart pimonitor.service

    If the pimonitor-apt-update.timer or its service unit changed, also run sudo systemctl restart pimonitor-apt-update.timer.

  4. Verify the new version is running:

    pimonitor -version
    systemctl status pimonitor.service
    journalctl -u pimonitor -n 20

Metric history survives the upgrade: with history_persist_enabled (the default), history is snapshotted to data_dir/history.bin — by default /var/lib/pimonitor/history.bin — and restored on startup, so the sparklines pick up where they left off rather than starting empty. Points older than history_window_minutes are dropped on restore.

There is no database and no migration step. If a release changes the history file format, the old file is simply ignored and history starts empty once — it is derived data that is always safe to discard. To deliberately reset the sparklines, stop the service, delete history.bin, and start it again:

sudo systemctl stop pimonitor.service
sudo rm -f /var/lib/pimonitor/history.bin
sudo systemctl start pimonitor.service

New configuration options: upgrades never modify your existing config.yaml. When a release adds settings, compare your file against the current packaging/pimonitor.example.yaml and copy over any new keys you want to use. All settings have sensible defaults, so a config from an older version keeps working unchanged.

REST API compatibility: the /api/v1/... contract is stable across updates — a breaking change to an existing key of a response ships as /api/v2/... instead (new keys are added to v1 and clients ignore keys they do not know), so existing integrations (e.g. openHAB) keep working after an upgrade. See docs/API.md.

REST API

See docs/API.md for the full contract, including an example openHAB HTTP Binding configuration. Quick example:

curl -s http://raspberrypi.local:8080/api/v1/metrics | jq '.cpu.overall_percent'

Integrations that only need one metric can poll its own endpoint instead of the full snapshot - the body is exactly that field of /api/v1/metrics:

curl -s http://raspberrypi.local:8080/api/v1/metrics/temperature

GET /healthz is a lightweight, unauthenticated liveness endpoint - point your monitoring system at it rather than an /api/v1/... route. It returns 503 instead of 200 when the latest collected snapshot is stale (e.g. a stalled collector), so it also doubles as a deeper healthcheck - see docs/API.md.

Integrations

  • openHAB — ready-to-use HTTP-binding .things / .items wiring PiMonitor's metrics into openHAB, plus a Prometheus (json_exporter) alternative.

Configuration

All settings have sensible defaults; override via /etc/pimonitor/config.yaml (see packaging/pimonitor.example.yaml) or CLI flags (-listen, -log-level, -api-key, -config, -version). Flags take precedence over the config file, which takes precedence over built-in defaults.

The API key additionally reads the PIMONITOR_API_KEY environment variable, which sits between the config file and the flags in precedence. Set the key via api_key in the config file (kept at mode 640 root:pimonitor by the installer), or via PIMONITOR_API_KEY from a systemd EnvironmentFile= with the same restricted permissions. The -api-key flag is for local development only — command lines are world-readable through /proc/<pid>/cmdline, so any local user could read the key.

The openHAB API token (openhab.api_token, optional) likewise reads the PIMONITOR_OPENHAB_TOKEN environment variable, which overrides the file value when non-empty; there is no flag for it. Without a token a default openHAB install refuses system info, Things and add-ons, and the card says "needs api_token". See docs/integrations/openhab.md.

Development

See docs/ARCHITECTURE.md for how the system is put together and why, docs/CONTRIBUTING.md for the contribution workflow, docs/UNIT_TESTS.md for test conventions (tests are mandatory for new code), .squad/stack.md for the build/test commands, and AGENTS.md for AI-agent guidance. Contributions are welcome - see the issue and pull request templates under .github/ for what to include.

License

MIT

About

Lightweight system-monitoring dashboard for the Raspberry Pi — CPU, temperature, memory, disk & network metrics, a self-contained web UI, a versioned REST API, and alert webhooks. Single Go binary, no database.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages