$ show hubblo-org/scaphandre
Scaphandre is a Rust-based CLI tool for monitoring electric power and energy consumption of hosts and processes. It reads RAPL (Running Average Power Limit) energy counters from Linux sysfs or Windows MSR, computes per-process power attribution using CPU usage ratios, and exports metrics via multiple backends: Prometheus (HTTP scrape or push gateway), JSON, stdout, Riemann, Warp10, and QEMU for virtual machines. The architecture is modular, built on `Sensor` and `Exporter` traits, allowing easy extension. It is packaged for Docker, Kubernetes (Helm chart), Linux (RPM/DEB), and Windows (installer with custom driver). The project is production-ready, actively maintained, and backed by extensive documentation and CI/CD pipelines. It is intended for infrastructure sustainability monitoring and carbon footprint tracking.
The LLM identified 3 files worth highlighting for reuse:
The `ProcessTracker` struct (within this module) manages per-process energy records, filtering by top consumers, and tracking CPU usage shares. It is a self-contained data structure that can be extracted and reused in any power monitoring or resource accounting system. It demonstrates non-obvious skill in efficiently handling process state over time without external dependencies beyond basic Rust primitives.
The `MetricGenerator` trait and `Metric` struct define a reusable pattern for collecting and aggregating metrics from various sources (host, socket, process, self) into a uniform vector. This trait decouples metric production from export, enabling any exporter to use the same collection logic. It can be extracted as a standalone metric collection framework for monitoring agents.
This module provides a simple, self-contained unit conversion system for energy (microjoules, millijoules, joules) and power (microwatts, milliwatts, watts). It implements `From` and `Into` traits for safe scaling. It is a pure utility that can be reused in any project requiring energy/power unit operations without modification.