We have quite a bit of expensive equipment in our server room and we’ve had the A/C fail a couple times. As a result, I’ve installed a raspberry pi zero with a DS18B20 temperature sensor connected to it to monitor the temperature of the room. If it goes above a set threshold, it will send an email to the engineers so we can log in and shut stuff down until the problem is fixed.
This project branches off from the one I did earlier on monitoring temperature with a raspberry pi and MRTG. This too uses MRTG but I won’t get into the details of that- you can see how I set that up here.
The big piece here is the alerting logic. You’d be surprised how fast the temp can go up in a small room with lots of gear putting out a lot of heat. For that reason, I monitor the temperature every minute. If the current temperature exceeds the threshold I set in the script, it fires an email and sets an alert flag to true. The reason I did this is so we don’t get an email every minute while the temperature is above threshold. How irritating would that be? So another piece of logic in the script checks to see if the alert flag has been tripped. If it has, no email is sent until the temperature comes down below the threshold. Then an all clear email is sent and the cycle repeats itself.
I used the instructions here to set up ssmtp on the pi. In my case, I used our comcast email relay since we have comcast so the instructions for that are a little different. You can also use your company’s own mail relay if you have one internally that can be used to send email to external addresses. As has been my practice lately, I’ve uploaded the code to GitHub here for you to do with as you please.
As always, if you have any constructive criticism or comments, feel free to leave them below and I’ll get back to you ASAP.