# Hottest core across every thermal zone and hwmon sensor lm-sensors knows # about. Reading the hottest rather than an average is deliberate: one core # throttling is a real problem that an average hides. local threshold={{ healthcheck_cpu_temp_threshold }} local hottest=0 label="" while read -r t; do [ -z "$t" ] && continue t=${t%.*} if [ "$t" -gt "$hottest" ]; then hottest=$t; fi done < <(sensors -u 2>/dev/null | awk '/_input:/ && /temp/ {print $2}') # Fall back to the kernel thermal zones if lm-sensors reports nothing. if [ "$hottest" -eq 0 ]; then for z in /sys/class/thermal/thermal_zone*/temp; do [ -r "$z" ] || continue local milli; milli=$(cat "$z" 2>/dev/null) || continue local c=$((milli / 1000)) if [ "$c" -gt "$hottest" ]; then hottest=$c; label=$(cat "${z%/temp}/type" 2>/dev/null); fi done fi if [ "$hottest" -eq 0 ]; then MESSAGE="no temperature sensors readable" return 1 fi MESSAGE="${hottest}C${label:+ (${label})}" [ "$hottest" -lt "$threshold" ]