go-freebsd-jails-exporter

A Prometheus exporter for FreeBSD jails — inventory, processes, RACCT resource usage and ZFS datasets — through native bindings. No shell commands are executed.

Goprometheus · jails · racct · grafanafreebsd from gosource on github

Why

Per-jail metrics across many hosts in Prometheus and Grafana, collected from kernel and library interfaces directly instead of by parsing command output. It’s the application that ties the FreeBSD libraries together.

How

  • Four pluggable collectors — jails, processes, RACCT, ZFS — run concurrently, each with its own timeout, and report their own scrape duration and error counts.
  • Jails via go-freebsd-jail. Processes via sysctl(KERN_PROC_ALL), grouped by jail id, with thread counts and run states.
  • RACCT via rctl_get_racct("jail:<name>"); the collector is skipped cleanly when kern.racct.enable is off.
  • ZFS via go-freebsd-libzfs: jail paths are matched to datasets by mountpoint, then used, available, quota and compression ratio are exported.
  • Every metric carries a host label. Ships with a Grafana dashboard, an rc.d script, health and readiness endpoints, and structured logging.

Requirements

Runs as root (otherwise security.bsd.see_other_uids=0 hides jail processes); RACCT needs kern.racct.enable=1 and a reboot.

CGO_ENABLED=1 go build -o go-freebsd-jails-exporter ./cmd/go-freebsd-jails-exporter/
doas ./go-freebsd-jails-exporter --web.listen-address=":9756"
$ git clone https://github.com/zombocoder/go-freebsd-jails-exporter
← all projects