All pastes #681659 Raw Edit

checktemp.sh

public shellscript v1 · immutable
#681659 ·published 2007-09-05 00:26 UTC
rendered paste body
##---- checktemp.sh  - Pull CPU temp Fan speeds from lm_sensors and Local outdoor temp from METARS (web site)#	              and HD temps from smartctl#. /usr/local/bin/setall >/dev/null 2>&1echo "Starting $0 `date`"nowtime=`date +%Y%m%d%H%M`##---- Pull local temp  #     Assumes odtemp.sh is running as a cron job###---- from#metar too slow outdoortemp=` grep ^Temperature /common_data/metar.$1.txt|sed 's/(//'|awk '{print $4}'`#metar too slow ttemp=`echo $outdoortemp|awk '{printf "%2d", $1}'`cd /common_data/metar/temprm -vf temp.txtecho "Temp in $1 as of `date`" >../$1.txtcurl -s http://weather.noaa.gov/weather/current/$1.html >temp.txtgrep " F (" temp.txt|head -n 1|awk '{print $3}' >> ../$1.txtttemp=`grep " F (" temp.txt|head -n 1|awk '{print $3}'`outdoortemp=$ttempecho "Outdoor: $outdoortemp "echo " " > /common_data/log/checktemp.last.txtecho "$0 at `date`" >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txt/etc/rc.d/init.d/lm_sensors status >> /common_data/log/checktemp.last.txtsensors > /common_data/log/sensors.last.txtcat /common_data/log/sensors.last.txt >> /common_data/log/checktemp.last.txt##---- Extract Important fields and write to csv log version#core0_temp=`head -n 4 /common_data/log/sensors.last.txt|grep "+"|sed 's/+//'|awk '{print $1}'`core1_temp=`head -n 6 /common_data/log/sensors.last.txt|tail -n 1 |grep "+"|sed 's/+//'|awk '{print $1}'`echo "Core0 $core0_temp  Core1 $core1_temp"cpufan=`grep "fan1"  /common_data/log/sensors.last.txt|awk '{print $2}'`sysfan=`grep "fan2"  /common_data/log/sensors.last.txt|awk '{print $2}'`ttemp=`grep "M/B Temp"  /common_data/log/sensors.last.txt|awk '{print $3}'`mbtemp=`echo $ttemp||awk '{printf "%2d", $1}'`cputemp=`cat /proc/acpi/thermal_zone/THRM/temperature|awk '{printf "%2d", $2}'`##---- Get HD temps from smartctl (Use output from hddtemp.smartctl.sh) cgslayer01 version##sda_temp=`grep "sda temp" /common_data/log/smarttemp.last.sda.txt|awk '{print $3}'`#JBBhdd_temp=`grep "sdb temp" /common_data/log/smarttemp.last.sdb.txt|awk '{print $3}'`## hddtemp format looks like#/dev/sda: HDS722580VLAT20: 31 C#/dev/sdb: SAMSUNG SP0842N: 34 Csda_status=`hdparm -C /dev/sda|grep drive|grep state|awk '{print "sda:"$4}'` sdb_status=`hdparm -C /dev/sdb|grep drive|grep state|awk '{print "sdb:"$4}'` hda_status=`hdparm -C /dev/hda|grep drive|grep state|awk '{print "hda:"$4}'` sda_temp=`hddtemp PATA:/dev/sda|awk '{print $3}'`echo "$nowtime,$sda_temp" >> /common_data/log/hddtemp.csvecho $sda_temp > /common_data/log/smarttemp.last.sda.txtchmod a+r /common_data/log/smarttemp.last.sda.txtsdb_temp=`hddtemp PATA:/dev/sdb|awk '{print $3}'`echo "$nowtime,$sdb_temp" >> /common_data/log/hddtemp.csvecho $sdb_temp > /common_data/log/smarttemp.last.sdb.txtchmod a+r /common_data/log/smarttemp.last.sdb.txthda_temp=`hddtemp /dev/hda|awk '{print $3}'`echo "$nowtime,$hda_temp" >> /common_data/log/hddtemp.csvecho $hda_temp > /common_data/log/smarttemp.last.hda.txtchmod a+r /common_data/log/smarttemp.last.hda.txtecho "$nowtime,$sda_temp,$sdb_temp,$hda_temp" >>/common_data/log/smarttemp.csvttemp=`echo $mbtemp|sed 's/+//'`mbtemp=$ttempecho "$nowtime,$outdoortemp,$cpufan,$sysfan,$core0_temp,$core1_temp,$sda_status,$sda_temp,$sdb_status,$sdb_temp,$hda_temp,$hda_status" >>/common_data/log/checktemp.csvecho "$nowtime,$outdoortemp,$cpufan,$sysfan,$core0_temp,$core1_temp,$sda_status,$sda_temp,$sdb_status,$sdb_temp,$hda_temp,$hda_status" echo " " >> /common_data/log/checktemp.last.txttail -n 60 /common_data/log/checktemp.csv >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtecho "Drive Status"  >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtecho "/dev/sda  $sda_status $sda_temp" >> /common_data/log/checktemp.last.txtecho "/dev/sdb  $sdb_status N/A" >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txt##---- Additional Information#echo " " >> /common_data/log/checktemp.last.txtuptime >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtusers  >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtmount >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtdf -h >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtfree -klt >> /common_data/log/checktemp.last.txtecho " " >> /common_data/log/checktemp.last.txtps -elf >> /common_data/log/checktemp.last.txt