This second part of the script APC Access Temperature Query Script and its been a long time coming. Basically this script is the part that runs as a cron and will e-mail me if the temperature goes over a certain threshold. Once it returns to normal it e-mails me again. It has the option to send a text message to me via my SMS gateway, but it is commented out.
if [ "`echo \"$temp > $threshold\" | bc`" == 1 ]; then
echo $(date +%s) $temp >> /home/linux/thermal-over.log
echo "High Temp";
if [ "$(cat temp.txt)" == "norm" ]; then
echo "Sending E-Mail, High Temp";
echo "Current Temperature Is: $(/home/linux/bin/temp f)" | mail -s "Thermal Overload" owen@linuxblog #echo "Current Temp Is: $(/home/linux/bin/temp f)" | mail -s "Thermal Overload" email@example.com
echo "high" > temp.txt
elif [ "`echo \"$temp < $threshold\" | bc`" == 1 ]; then
echo "Low Temp";
if [ "$(cat temp.txt)" == "high" ]; then
echo "Temp Resumed, Sending E-Mail";
echo $(date +%s) Resumed at: $temp | mail -s "Thermal Normal" owen@linuxblog
echo "norm" > temp.txt
echo $(date +%s) $temp >> /home/linux/thermal.log
When I first wrote the script, I did not do any temperature checking. I found out that I needed to when I came back one morning with a bunch of emails that I needed to delete. Its pretty simple to figure out, temp.txt holds a value that is either norm or high. It gets switched when the temperature changes, this will in turn stop it from e-mailing me repeatedly. Once the temperature drops it flips it back. It will still e-mail if your temperature fluctuates between 75 and 77 which can be annoying, but you can adjust the threshold with the variable and set it to what you need. Thankfully our chiller has been fixed and I no longer have to worry about the temperature, but it still runs on a cron just in case.