Skip to content

Instantly share code, notes, and snippets.

@FlorianHeigl
Last active March 24, 2025 18:17
Show Gist options
  • Save FlorianHeigl/02148e5cb218de70a281bc4bfd2900fb to your computer and use it in GitHub Desktop.
Save FlorianHeigl/02148e5cb218de70a281bc4bfd2900fb to your computer and use it in GitHub Desktop.
Cavium CN7322 / Marvell LiquidIO II CN2360 Thermal Sensors
cn7322:/usr/lib/check_mk_agent/plugins# ls -l /sys/class/hwmon/hwmon0/
total 0
-r--r--r-- 1 root root 4096 Mar 21 15:07 alarms
lrwxrwxrwx 1 root root    0 Mar 21 15:07 device -> ../../../0-004c
-r--r--r-- 1 root root 4096 Mar 21 15:07 name
lrwxrwxrwx 1 root root    0 Mar 21 15:07 of_node -> ../../../../../../../../firmware/devicetree/base/soc@0/i2c@1180000001000/tmp@4c
drwxr-xr-x 2 root root    0 Mar 21 15:07 power
lrwxrwxrwx 1 root root    0 Mar 21 15:07 subsystem -> ../../../../../../../../class/hwmon
-rw-r--r-- 1 root root 4096 Mar 21 15:07 temp1_crit
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp1_crit_alarm
-rw-r--r-- 1 root root 4096 Mar 21 15:07 temp1_crit_hyst
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp1_input
-rw-r--r-- 1 root root 4096 Mar 21 15:07 temp1_max
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp1_max_alarm
-rw-r--r-- 1 root root 4096 Mar 21 15:07 temp1_min
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp1_min_alarm
-rw-r--r-- 1 root root 4096 Mar 21 15:07 temp2_crit
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp2_crit_alarm
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp2_crit_hyst
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp2_fault
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp2_input
-rw-r--r-- 1 root root 4096 Mar 21 15:07 temp2_max
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp2_max_alarm
-rw-r--r-- 1 root root 4096 Mar 21 15:07 temp2_min
-r--r--r-- 1 root root 4096 Mar 21 15:07 temp2_min_alarm
-rw-r--r-- 1 root root 4096 Mar 21 15:07 temp2_offset
-rw-r--r-- 1 root root 4096 Mar 21 15:07 uevent
-rw-r--r-- 1 root root 4096 Mar 21 15:07 update_interval
#!/usr/bin/env bash
# angepasst auf basis von https://gitlab.com/pers-proj/monitoring-extensions/check_lnx_thermal_hwmon/-/blob/master/agents/plugins/lnx_thermal_hwmon.sh?ref_type=heads
# (der Treiber definiert kein label)
set -eu
echo "<<<lnx_thermal:sep(124)>>>"
for hwmon in /sys/class/hwmon/hwmon*; do
for F in "${hwmon}"/temp*_input; do
if ! [ -f "$F" ]; then
continue
fi
sensor="${F##*/}"
sensor_base="${F%_input}"
label_file="${sensor_base}_label"
if [ -f "$label_file" ]; then
read -r label < "$label_file"
else
#continue
label=${sensor}
fi
device="$(readlink "${hwmon}/device")"
# Ignore thermal_zone originated hwmon, since that's covered by
# by the stock agent
case "$device" in
../../thermal_zone*)
continue
;;
esac
if ! read -r F < "$F"; then
continue
fi
read -r device_name < "${hwmon}/name"
# name | mode | type (unused) | temperature
line="${device_name}_${sensor}|-|${hwmon##*/}_$sensor|${F}"
max_temp_file="${sensor_base}_max" # max temp (if present)
if [ -f "$max_temp_file" ]; then
read -r max_temp < "$max_temp_file"
line="${line}|${max_temp}|critical"
fi
max_hyst_temp_file="${sensor_base}_max_hyst" # "warn" temp (if present)
if [ -f "$max_hyst_temp_file" ]; then
read -r max_hyst_temp < "$max_hyst_temp_file"
line="${line}|${max_hyst_temp}|hot"
fi
echo "$line"
done
done
echo "<<<>>>"
<<<lnx_thermal:sep(124)>>>
sa56004_temp1_input|-|hwmon0_temp1_input|33625|80000|critical
sa56004_temp2_input|-|hwmon0_temp2_input|46375|85000|critical
<<<>>>
@FlorianHeigl
Copy link
Author

FlorianHeigl commented Mar 22, 2025

Achtung

  • alarmwerte und ihre verarbeitung nicht getestet
  • im u-boot environment irgendwo bei den I2C sachen findet man hinweise auf 3 verschiedene Sensorchips, hier nicht

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment