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
+2
View File
@@ -86,6 +86,8 @@ func main() {
os.Exit(space.Helper(flag.Args()[1:], os.Stdin, os.Stdout, os.Stderr))
case "drm-clients": // privileged helper for the GPU readings: who has the GPU open (run as root by the daemon)
os.Exit(metrics.DRMClientsHelper(os.Stdin, os.Stdout))
case "cpu-energy": // privileged helper for the CPU power reading: the packages' energy counters (run as root by the daemon)
os.Exit(metrics.CPUEnergyHelper(os.Stdin, os.Stdout))
case "install", "uninstall":
var err error
if cmd == "install" {