The sensors package seems to be working fine. Here's the output:
Code:
****@****:~$ sudo sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +40.0°C (crit = +65.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +41.0°C (high = +80.0°C, crit = +99.0°C)
Core 0: +40.0°C (high = +80.0°C, crit = +99.0°C)
Core 1: +39.0°C (high = +80.0°C, crit = +99.0°C)
Core 2: +37.0°C (high = +80.0°C, crit = +99.0°C)
Core 3: +39.0°C (high = +80.0°C, crit = +99.0°C)
And then I modified your script to be:
Code:
#!/bin/bash
LOG=/usr/bin/logger
DOWN=/sbin/shutdown
ALERT_LEVEL=80
SENSORSCMD=sensors
CORE0TEMP=$($SENSORSCMD | grep -i "Core 0" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
CORE1TEMP=$($SENSORSCMD | grep -i "Core 1" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
CORE2TEMP=$($SENSORSCMD | grep -i "Core 2" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
CORE3TEMP=$($SENSORSCMD | grep -i "Core 3" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
if [[ $CORE0TEMP =~ "^[0-9]+$" ]]; then
if [ $CORE0TEMP -ge $ALERT_LEVEL ]; then
echo "The server **** is shutting down due to excessive Core 0 temp (it has reached a temperature of $CORE0TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
$LOG "System going down as Core 0 has crossed its limit (temp=$CORE0TEMP°C, limit=$ALERT_LEVEL°C"
sync;sync
$DOWN -h 0
fi
fi
if [[ $CORE1TEMP =~ "^[0-9]+$" ]]; then
if [ $CORE1TEMP -ge $ALERT_LEVEL ]; then
echo "The server **** is shutting down due to excessive Core 1 temp (it has reached a temperature of $CORE1TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
$LOG "System going down as Core 1 has crossed its limit (temp=$CORE1TEMP°C, limit=$ALERT_LEVEL°C"
sync;sync
$DOWN -h 0
fi
fi
if [[ $CORE2TEMP =~ "^[0-9]+$" ]]; then
if [ $CORE2TEMP -ge $ALERT_LEVEL ]; then
echo "The server **** is shutting down due to excessive Core 2 temp (it has reached a temperature of $CORE2TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
$LOG "System going down as Core 2 has crossed its limit (temp=$CORE2TEMP°C, limit=$ALERT_LEVEL°C"
sync;sync
$DOWN -h 0
fi
fi
if [[ $CORE3TEMP =~ "^[0-9]+$" ]]; then
if [ $CORE3TEMP -ge $ALERT_LEVEL ]; then
echo "The server **** is shutting down due to excessive Core 3 temp (it has reached a temperature of $CORE3TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
$LOG "System going down as Core 3 has crossed its limit (temp=$CORE3TEMP°C, limit=$ALERT_LEVEL°C"
sync;sync
$DOWN -h 0
fi
fi
Probably unnecessary to do all 4 cores since they're on the same chip, but I was a little fuzzy last night. If I get motivated and actually figure out how to write scripts I'll probably change to use just the Physical ID.
When I set the ALERT_LEVEL to 1 and run it just does nothing at all. No shut down, no email. Just another command line. All the previous scripts have generated the appropriate emails and shutdowns.
ETA: I just noticed that there's no "do" and "done" in the sensors_monitor.sh script. I think there should be, but I'm not really sure.
Bookmarks