Thermal Shutdown

Discussion and Technical Support for general software applications and utilities including OS related issues.
Post Reply
Aidanb
Member
Member
Posts: 3
Joined: July 27th, 2012, 5:53 pm

Thermal Shutdown

Post by Aidanb »

Hi,

Firstly great website and very useful, I am trying to get the cpu temp script working I have looked on here and done the commands you suggest here is the sensors

Code: Select all

Adapter: ISA adapter
Physical id 0:  +36.0°C  (high = +82.0°C, crit = +102.0°C)
Core 0:         +33.0°C  (high = +82.0°C, crit = +102.0°C)
Core 1:         +35.0°C  (high = +82.0°C, crit = +102.0°C)

nct6776-isa-0290
Adapter: ISA adapter
Vcore:         +0.74 V  (min =  +0.00 V, max =  +1.74 V)
in1:           +1.02 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:          +3.44 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V:         +3.42 V  (min =  +2.98 V, max =  +3.63 V)
in4:           +1.02 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:           +0.00 V  (min =  +0.00 V, max =  +0.00 V)
3VSB:          +3.39 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:          +3.39 V  (min =  +2.70 V, max =  +3.30 V)  ALARM
fan1:            0 RPM  (min =    0 RPM)  ALARM
fan2:         1147 RPM  (min =    0 RPM)  ALARM
fan3:            0 RPM  (min =    0 RPM)  ALARM
fan4:            0 RPM  (min =    0 RPM)  ALARM
fan5:            0 RPM  (min =    0 RPM)  ALARM
SYSTIN:        +63.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = the                                                                                                 rmistor
CPUTIN:        -60.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = diode
AUXTIN:        +35.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
PECI Agent 0:  +25.5°C
cpu0_vid:     +2.050 V
intrusion0:   ALARM
intrusion1:   ALARM


when i do an echo ${newstr:14:2} to show the output there is nothing all i get in the script output is;

Code: Select all

./CPUTempShutdown.sh: line 49: [: -ge: unary operator expected
./CPUTempShutdown.sh: line 59: [: -ge: unary operator expected
 Temperature Core 0 OK at =>

./CPUTempShutdown.sh: line 49: [: -ge: unary operator expected
./CPUTempShutdown.sh: line 59: [: -ge: unary operator expected
 Temperature Core 1 OK at =>


Hope you can help me with this and can you explain the ${newstr:14:2}

regards

Aidan
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Thermal Shutdown

Post by Ian »

Hi Aidan and welcome to the forums.

The ${newstr:14:2} looks at the 2 characters starting at position 14. Looking at your output you need to start at position 17. So, ${newstr:17:2}

Basically you're trying to pull out the 33 and 35 from the output below:

Code: Select all

Core 0:         +33.0°C  (high = +82.0°C, crit = +102.0°C)
Core 1:         +35.0°C  (high = +82.0°C, crit = +102.0°C)

Try that and let me know how you get on. :thumbup:

Ian.
Aidanb
Member
Member
Posts: 3
Joined: July 27th, 2012, 5:53 pm

Re: Thermal Shutdown

Post by Aidanb »

Thanks Ian that worked great.

Regards

Aidan
telemarker7
Member
Member
Posts: 1
Joined: January 13th, 2014, 1:36 am

Re: Thermal Shutdown

Post by telemarker7 »

This worked for me as well. Thanks.
kjtknowit
Member
Member
Posts: 2
Joined: August 22nd, 2014, 2:41 am

Re: Thermal Shutdown

Post by kjtknowit »

Hi all, I am new to the forum. I have built a media server, and found your Thermal shutdown script. I modified the script on your site (for my own email, home directory, etc.) but I am getting errors when i run it manually or via cron job.

this is what it is returning:
./CPUTempShutdown.sh: line 1: POSE:: command not found

when I type "sensors", I get this output

coretemp-isa-0000
Adapter: ISA adapter
Core 0: +38.0°C (high = +80.0°C, crit = +100.0°C)
Core 1: +37.0°C (high = +80.0°C, crit = +100.0°C)
Core 2: +38.0°C (high = +80.0°C, crit = +100.0°C)
Core 3: +36.0°C (high = +80.0°C, crit = +100.0°C)

atk0110-acpi-0
Adapter: ACPI interface
Vcore Voltage: +1.06 V (min = +0.80 V, max = +1.60 V)
+3.3 Voltage: +3.26 V (min = +2.97 V, max = +3.63 V)
+5 Voltage: +5.14 V (min = +4.50 V, max = +5.50 V)
+12 Voltage: +11.97 V (min = +10.20 V, max = +13.80 V)
CPU FAN Speed: 2280 RPM (min = 600 RPM, max = 7200 RPM)
CHASSIS1 FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
CHASSIS2 FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
CHASSIS3 FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
POWER FAN Speed: 0 RPM (min = 0 RPM, max = 7200 RPM)
CPU Temperature: +51.0°C (high = +60.0°C, crit = +75.0°C)
MB Temperature: +57.0°C (high = +45.0°C, crit = +75.0°C)

radeon-pci-0300
Adapter: PCI adapter
temp1: +146.0°C


FYI I am running Ubuntu Server 14.04. I also set the server up to email me any problems, etc, so I'd like to get warning emails about temp, etc. I followed this guide for email alerts:
http://www.howtogeek.com/51819/how-to-s ... ing-gmail/


Thank you for any help
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Thermal Shutdown

Post by Ian »

Hi there,

Can you paste your CPUTempShutdown.sh script into your next post please?

Thanks,

Ian.
kjtknowit
Member
Member
Posts: 2
Joined: August 22nd, 2014, 2:41 am

Re: Thermal Shutdown

Post by kjtknowit »

Hi Ian, thanks so much. here is the script:


#
# AUTHOR: feedback[AT]HaveTheKnowHow[DOT]com

# Expects two arguments:
# 1. Warning temperature
# 2. Critical shutdown temperature
# eg. using ./CPUTempShutdown.sh 30 40
# will warn when temperature of one or more cores hit 30degrees and shutdown when either hits 40degrees.

# NOTES:
# Change the strings ">>/home/htkh" as required
# Substitute string "myemail@myaddress.com" with your own email address in the string which starts "/usr/sbin/ssmtp myemail@myaddress.com"

# Assumes output from sensors command is as follows:
#
# coretemp-isa-0000
# Adapter: ISA adapter
# Core 0: +35.0 C (high = +78.0 C, crit = +100.0 C)
#
# coretemp-isa-0001
# Adapter: ISA adapter
# Core 1: +35.0 C (high = +78.0 C, crit = +100.0 C)
#
# if not then modify the commands str=$(sensors | grep "Core $i:") & newstr=${str:14:2} below accordingly

echo "JOB RUN AT $(date)"
echo "======================================="

echo ''
echo 'CPU Warning Limit set to => '$1
echo 'CPU Shutdown Limit set to => '$2
echo ''
echo ''

sensors

echo ''
echo ''

for i in 0 1
do

str=$(sensors | grep "Core $i:")
newstr=${str:14:2}

if [ ${newstr} -ge $1 ]
then
echo '============================' >>/home/kjt/Desktop/CPUWarning.Log
echo $(date) >>/home/kjt/Desktop/CPUWarning.Log
echo '' >>/home/kjt/Desktop/CPUWarning.Log
echo ' WARNING: TEMPERATURE CORE' $i 'EXCEEDED' $1 '=>' $newstr >>/home/kjt/Desktop/CPUWarning.Log
echo '' >>/home/kjt/Desktop/CPUWarning.Log
echo '============================' >>/home/kjt/Desktop/CPUWarning.Log
fi

if [ ${newstr} -ge $2 ]
then
echo '============================'
echo ''
echo 'CRITICAL: TEMPERATURE CORE' $i 'EXCEEDED' $2 '=>' $newstr
echo ''
echo '============================'
/sbin/shutdown -h now
/usr/sbin/ssmtp XXX@XXXXX.com </home/kjt/MyScripts/msg.txt
echo 'Email Sent.....'
exit
else
echo ' Temperature Core '$i' OK at =>' $newstr
echo ''
fi
done
echo 'Both CPU Cores are within limits'
echo ''
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Thermal Shutdown

Post by Ian »

Hi there,

Thanks. Assuming it's not a problem with your post then you're missing this line from your script which should be at the very top:

Code: Select all

#!/bin/bash
So your script should read......

Code: Select all

#!/bin/bash
#
# AUTHOR: feedback[AT]HaveTheKnowHow[DOT]com

# Expects two arguments:
etc......
Post Reply