Quick Hack to email CPU lmsensors thresholds

Below is a quick hack I did that I thought folks might find useful. I used it to watch the CPU temps of a system in a VERY warm room. More a exercise but someone might find it useful :)

#!/bin/sh
EMAIL=YOUREMAILHERE
SENSOR=coretemp-isa-0000
MAXTEMP=50
MESSAGE=/dev/null
HOSTNAME=$(hostname)

for t in $(sensors -u $SENSOR | grep input | awk -F: ‘{printf “% .0f”, $2}’); do
if [ $t -gt $MAXTEMP ] ;
then mail -s “$(echo “CPU in $HOSTNAME at “$t”C”)” $EMAIL < $MESSAGE;
fi;
done

Leave a Reply