Skip to content

Instantly share code, notes, and snippets.

@JMac87 JMac87/ Secret
Last active Feb 21, 2018

What would you like to do?
pfSense - Temperature Alert Script
#description :This script will find the average temperature of
# the CPU and fire off an email if this temperature
# is over a set limit ($alert).
#author :Justin Maciak
#date :20160725
#version :1.0
#usage :./
#Change the following number to the temperature you'd like to be alerted at
#Get number of CPU cores
ncpu=$( sysctl hw.ncpu | awk '{ print $2 }' )
#Set hostname
#Get temperature
get_temp() {
for c in `jot ${ncpu} 0`; do
temp=$( sysctl dev.cpu.${c}.temperature | sed -e 's|.*: \([0-9.]*\)C|\1|' )
avg=$( echo "${avg} + ${temp}" | bc )
avg=$( echo "${avg} / (${ncpu})" | bc )
#Compare current average temperature to alert threshold, email if equal or over
if [ "$avg" -gt "$alert" ]; then
echo "WARNING: ${thishost} is currently at ${avg}C, which is over the alert threshold of ${alert}C" | /usr/local/bin/php -q /usr/local/bin/mail.php -s"ALERT: ${thishost} Temperature At ${avg}C"
exit 1;
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.