Files
mesh-catalog/modules/power/files/bin/power-draw
T
jochen e1b7fcd8c9 Count each processor package once, never read a sleeping card, and give no reading for a reset counter (hq ADR 0255)
Intel shows some packages twice (MSR and MMIO), an AMD card's sensors wake it, and a
counter reset after resume read as thousands of watts. The loop's cadence and the bar
script's staleness are now tested, and the sampler running on every machine is said.
2026-10-08 16:12:37 +02:00

13 lines
555 B
Bash
Executable File

#!/bin/sh
# power-draw (module power, novox/hq ADR 0255): the power the machine draws, for the bar's block.
#
# Prints the line the module's sampler (`power draw`, as root) publishes every five seconds, which says
# what it measured: "machine" on battery, "CPU" or "CPU+GPU" otherwise. A line older than thirty
# seconds is a sampler that stopped, and is not shown as if it were now.
f="${MESH_POWER_DRAW:-/run/mesh-power/draw}"
if [ -r "$f" ] && [ $(( $(date +%s) - $(stat -c %Y "$f") )) -le 30 ]; then
head -n 1 "$f"
else
echo "power not measured"
fi