From bfedf622bea7946e78f0911344028ddbd258fd22 Mon Sep 17 00:00:00 2001 From: Mitchell-Johnson Date: Sat, 10 Oct 2026 23:58:35 -0700 Subject: [PATCH] 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 --- SENSORS.md | 7 +- cmd/hamlab/main.go | 2 + internal/metrics/cpupower.go | 259 ++++++++++++++++++++++++++++++ internal/metrics/cpupower_test.go | 106 ++++++++++++ internal/metrics/fold.go | 11 ++ internal/metrics/metrics.go | 10 +- internal/metrics/sensors.go | 3 + web/src/Top.tsx | 3 +- web/src/api.ts | 2 +- 9 files changed, 398 insertions(+), 5 deletions(-) create mode 100644 internal/metrics/cpupower.go create mode 100644 internal/metrics/cpupower_test.go diff --git a/SENSORS.md b/SENSORS.md index 18fec25..206f325 100644 --- a/SENSORS.md +++ b/SENSORS.md @@ -12,7 +12,7 @@ added to the registry in `api.New`. ## IDs ``` -cpu.usage cpu.core..usage cpu.temp load.1|5|15 uptime +cpu.usage cpu.core..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..