Skip to content

Commit

Permalink
Add error handling if missing lm-sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
NEMSLinux committed May 26, 2020
1 parent c415ecd commit 9d4f242
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion data/1.6/nagios/plugins/check_rpi_temperature
Expand Up @@ -55,7 +55,18 @@ fi
if [[ -e /var/log/nems ]]; then
TEMP=`/usr/local/bin/nems-info temperature`
else
TEMP=`sensors | grep Core | tr '+°C' ' ' | awk '{print $3}' | head -n 1`
sensors=`which sensors`
if [[ ! $sensors == '' ]]; then
TEMP=`sensors | grep Core | tr '+°C' ' ' | awk '{print $3}' | head -n 1`
fi
if [[ $TEMP == '' ]] && [[ -e /sys/class/thermal/thermal_zone0/temp ]]; then
# this is a dirty way to try to figure it out since it doesn't tell which temp unit we're using... but it may help on some systems... can improve it later
TEMP=`awk '{printf "%3.1f", $1/1000}' /sys/class/thermal/thermal_zone0/temp`
fi
if [[ $TEMP == '' ]]; then
echo "UNKNOWN - Thermal sensor doesn't exist or lm-sensors not installed"
exit 3
fi
fi

if (( $(echo "${TEMP} > ${CRIT}" | bc -l) )); then
Expand Down

0 comments on commit 9d4f242

Please sign in to comment.