Processes: CPU power beside the clock, from the packages' energy counters

New sensor cpu.power: watts from the RAPL energy counters (Intel, and AMD
Zen through the same driver), summed over every package and averaged into
history. Parts of a package, psys and the MMIO duplicate are left out.

The counters are root-only, so a daemon that isn't root reads them through
`hamlab cpu-energy`, a root helper started once with sudo or doas and asked
over a pipe each sample, the same shape as the GPU client walk's helper.
It reads only the counters it finds itself. No counters or no root means
no reading, and the CPU box shows nothing extra.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mitchell-Johnson
2026-10-10 23:58:35 -07:00
co-authored by Claude Opus 5.5
parent d5680e8e41
commit bfedf622be
9 changed files with 398 additions and 5 deletions
+6 -1
View File
@@ -12,7 +12,7 @@ added to the registry in `api.New`.
## IDs
```
cpu.usage cpu.core.<n>.usage cpu.temp load.1|5|15 uptime
cpu.usage cpu.core.<n>.usage cpu.temp cpu.power load.1|5|15 uptime
mem.total|used|avail|free|cached|buffers|used_pct swap.total|used|avail|used_pct
temp.<chip>.<label> fan.<chip>.<label>
net.<iface>.rx|tx|rx_total|tx_total|up
@@ -35,6 +35,11 @@ zfs.arc.size|target|min|max|mru|mfu|data|metadata|hit_pct|reads|misses|lifetime_
has run on that machine, and each one's `t` is when it ran — so a widget or an alert on
them is reading a measurement from that moment, not a live value. Nothing takes a speed
test on its own; something has to press the button.
- `cpu.power` is the CPU packages' own power in watts, from the kernel's RAPL energy
counters (Intel, and AMD Zen), summed over every package: cores, built-in graphics and
memory controller, not the whole machine. The counters are root-only, so a daemon that is
not root reads them through a helper started once with sudo or doas. It is absent on a
machine without the counters (ARM, the Mac mini) or without a way to root.
- `gpu.<name>.*` is each graphics device, named as lspci names it (`gpu.intel_arc_a380`;
labels carry `driver` and the PCI `bus`). `usage` is how busy the device was — from the
GT's idle residency on Intel, `gpu_busy_percent` on amdgpu — and is absent on a driver