A lightweight Linux tool to monitor processes and estimate their power/energy consumption
using CPU utilization, disk I/O, and memory activity as proxies.
-
Process-level monitoring
- Accepts single PIDs, multiple PIDs, or ranges (
1000..1010). - Works with process trees via
pstreeexpansion.
- Accepts single PIDs, multiple PIDs, or ranges (
-
Multiple output formats
- Human-readable table (default).
- CSV and JSON streams for machine processing.
- Self-contained HTML report with summary and per-tick table.
-
Configurable model
- Idle power, max power, and CPU nonlinearity exponent.
- Disk energy per byte read/write.
- Memory RSS churn and refault energy.
- Adjustable idle-share distribution (
--alpha).
-
Post-processing tools
calcsubcommand computes averages from a saved CSV/JSON report.
-
Safe defaults
- Ships with reasonable coefficients for typical laptop/server workloads.
- All parameters are overrideable via CLI flags.
Install directly from source using go install:
go install github.com/ja7ad/consumption/cmd/consumption@latestThis will place the consumption binary in your $GOPATH/bin or $HOME/go/bin.
This tool requires cgroup v1 or v2 with sudo privileges to read process stats.
Prebuilt binaries are available on the Releases page.
Download the latest release for your platform and place it in your $PATH.
consumption -s 10 -i 1s $(pidof nginx)Collects 10 samples at 1 second interval for the nginx process.
consumption -s 20 -i 1s $(pstree -p $(pidof goland) | grep -o '([0-9]\+)' | tr -d '()' | tr '\n' ' ')Expands all child PIDs of GoLand and monitors them together.
consumption -s 0 -i 500ms -- $(pidof postgres)Runs indefinitely (until Ctrl-C), sampling every 500ms.
consumption --csv out.csv --json out.json -- $(pidof redis-server)Outputs per-tick rows to both CSV and JSON.
consumption --html report.html -- $(pidof mysqld)Produces a full HTML report with averages, energy totals, and per-tick data.
consumption calc out.csvReads an existing CSV/JSON report and calculates average consumption:
consumption avg (over 18 samples of ~1s):
- watt (cpu): 0.013 W
- watt (disk): 0.000 W
- watt (ram): 0.000 W
- watt (total): 0.013 W
Instead, Consumption builds a model that estimates process power by combining CPU utilization, I/O, and memory activity with calibrated coefficients.
-
$N$ : number of vCPUs -
$\Delta t$ : sampling interval (seconds) -
$U_{\text{proc}}$ : process CPU utilization fraction
$U_{\text{proc}}=\dfrac{\text{CPU time of process in sec during }\Delta t}{N \cdot \Delta t}$ -
$U_{\text{vm}}$ : total VM CPU utilization fraction
$U_{\text{vm}}=\dfrac{\text{CPU time of all tasks}}{N \cdot \Delta t}$ -
$P_{\text{idle}}$ : idle power in Watts (configurable) -
$P_{\text{max}}$ : max power in Watts at 100% utilization -
$\gamma$ : CPU nonlinearity exponent - Disk bytes:
$B_r$ (read),$B_w$ (write) - Memory proxies:
-
RefaultB= refaulted bytes -
RSSChurnB= RSS churn bytes
-
- Energy per byte coefficients:
-
$e_r$ (disk read),$e_w$ (disk write) -
$e_{\text{ref}}$ (RAM refault),$e_{\text{rss}}$ (RSS churn)
-
Dynamic VM power grows nonlinearly with utilization:
Total VM power at utilization
Each process is charged a share of VM dynamic power:
If policy requires spreading idle cost, an
-
$\alpha=0$ : no idle charged (default) -
$\alpha=1$ : full idle proportionally shared
Convert per-byte activity to Joules, then divide by
Total instantaneous power:
Cumulative energy (Joules) is the time integral:
-
Network I/O: add a term
$e_n \cdot N_b$ with$e_n$ = energy per byte transferred. -
Device-specific coefficients: tune
$e_r$ ,$e_w$ ,$e_{\text{ref}}$ ,$e_{\text{rss}}$ for different hardware.