Temperature Alert Script
-
I wrote a simple shell script to send an email alert when the average CPU temperature reaches a set threshold. It uses the php mail feature within PfSense since there is no "mail" command available.
I'm using our firewall as a sort of temperature monitor for our server room, which frequently has HVAC issues. Instead of buying some sort of temperature monitor, I figured I'd just use the average temperature of the CPU and send an alert when it hits a certain temperature that is known to exist when our HVAC system is off/broken.
I'm sure you guys could integrate this into the GUI for others to easily use, since pfSense has no such built-in function.
https://gist.github.com/JMac87/1303f78c56a54165447568318eeca3b3
Notes:
You must set up a notification email in System > Advanced > Notifications.I had to edit /etc/inc/notices.inc to include:
require_once("functions.inc");
You can cron this script to run every X minutes or whatever interval you'd like to check.
-
Im amazed that pfsense is still not capable of sending a email notification when system or CPU temp goes above a set value. All the pieces are there, its just to connect them together.
-
Email notification is there
-
CPU temp measurement is there
-
System temp measurement is there
Whats the show stopper to integrate a GUI page to enter a treshold and set a checkbox to "Notify if above this value?"
What about smart temps for HDDs??
Freenas does this seamlessly AFAIK. If I had any coding skills I'd attempt something on a VM but things as they are, I know nothing about coding. ???
Hardware monitoring and notification (temps, RAM and HDD status) are definitely something I'd be interested into.
-
-
Agreed… seems like an easy add, and could save someone's hardware from frying if a fan died.
-
The stopper is primarily that we don't have a periodic polling script for monitoring those conditions. They are only displayed in the GUI when the dashboard is loaded. It's not difficult to add, but it would also need a GUI to control its settings (e.g. alert thresholds). Also support for temp sensors varies from system to system and hardware quirks with temp sensors make them not 100% reliable, so it may be something we'd have to restrict to hardware we can assure it will work for (e.g. systems we sell).
-
Worked like a charm.
Now I need a script for CPU usage so if the CPU is pinned by suricata, I will be notified. It has happened to me on many occasions. -
Jimp is right, this type of monitoring needs a lot of manual configuration because on many systems the readings are nonsensical unless adjusted properly using information from the manufacturer. For example some of the AMD CPUs give you negative values and you're supposed to know the reference temperature used to calculate the real temperature as reference+reported. On such systems the only out of the box reliable CPU temperature is the one show in BIOS setup.
Such reporting system would work out of the box only on a small number of systems where the calibration values are known.
-
Leaving this here in case it's useful to anyone...