Last active
August 16, 2024 18:19
-
-
Save TETYYS/b2d2636921143f99bf2412cd9cae43ff to your computer and use it in GitHub Desktop.
Translates hwmon disk temp chip id to device model. Use with max(node_hwmon_temp_celsius{chip=~"^target(.+)"}) by (chip) * on(chip) group_left(model) (node_hwmon_chip_info)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
metrics() { | |
echo "# HELP node_hwmon_chip_info chip to model name mapping" | |
echo "# TYPE node_hwmon_chip_info gauge" | |
for file in /sys/class/hwmon/*; do | |
symlink_target="$(readlink $file)" | |
if [[ "$symlink_target" != *"/target"* ]]; then | |
continue | |
fi | |
chip="$(echo "$symlink_target" | sed -E 's/^.+target(.+)\/hwmon\/hwmon[[:digit:]]+/target\1/' | sed 's/\//_/')" | |
block=($file/device/block/*) | |
model="$(udevadm info --query=property --path="$block" | grep -m 1 ID_SERIAL | sed 's/ID_SERIAL=//')" | |
echo "node_hwmon_chip_info{chip="'"'$chip'"'",model="'"'$model'"'"} 1.0" | |
done | |
} | |
metrics > /var/lib/prometheus/node-exporter/chip_info.prom |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment