shutdown-script using lm-sensors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I wanted to monitor the temperature of a server and shut it down 
automatically when it reaches certain threshold. At the same time it 
should keep me informed about the status via email.

I found that 
http://cahbojonegoro.wordpress.com/2008/12/15/cpu-temperature-monitor-script/
script and changed it a little:

#!/bin/sh

### Temperature Monitor
### Auto Shutdown if CPU Temperature is over threshold

## Define threshold for CPU Temperature
threshold=75

## Get CPU Temperatur using lm-sensor
t1=`/usr/bin/sensors | nawk ?/temp2/ {print substr($2,2,2)}?`

if test $t1 -gt $threshold
then
mail -s "safety-shutdown" name at domain.de < /home/chris/heat.txt
echo ?CPU Temperature is exceeding threshold ? Shutting down in 10 sec ??.?
sleep 10
shutdown -h now
else
mail -s "test" name at domain.de < /home/chris/textdatei.txt
echo ?Temperature still on the safe range ?
echo ?CPU: $t1?C?
fi


Cronjob is runnig the script periodically. lm-sensors itself as well as 
the email-thing work well, but it seems that the script doesn't get the 
needed info from lm-sensors. My error-message is:

nawk: 1: unexpected character 0xe2
test: 23: 75: unexpected operator
???Temperature still on the safe range ???
???CPU: ??C???

Since I don't have much experience with scripts, I don't really 
understand what the problem could be. Any suggestions what do do?

I am using Ubuntu Linux 8.04.2 kernel 2.6.24-24, the mainboard is an 
Asus Pundit-R AB-P 2800 using an it8712-isa-0260 chip.**
****
**
**Thanks a lot in advance and greets from Bavaria!
**
**Chris



[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux