#!/bin/bash#DATE 2013-07-09#AUTHOR charlie_cen#EMAIL cenhuqing@gmail.com#SITE http://charlie928.blog.51cto.comyum clean all > /dev/null 2>&1yum makecache > /dev/null 2>&1if [ $? -eq 0 ]then echo "yum is OK"else echo "yum is wrong" exit 5fiif [ -e /usr/bin/sensors ]then echo "sensors was installed"else yum install -y lm_sensors if [ $? -eq 0 ] then echo "sensors was installed" sh -c "yes|sensors-detect" > /dev/null 2>&1 else echo "sensors was not install" exit 2 fifidir=/usr/local/nagios/libexeccat >> $dir/check_temp.sh << EOF #!/bin/bash sensors |awk '{print $3}' |egrep '^\+' |sed 's/\+//' |while read temp do if [[ $temp > 70 ]] then echo "$temp is critcal" else echo "$temp is normal" fi doneEOFif [ -e $dir/check_temp.sh ]then chmod +x $dir/check_temp.sh chown nagios. $dir/check_temp.shelse echo "check_temp.sh is not exist" exit 2fidir1=/usr/local/nagios/etcif [ -e $dir1/nrpe.cfg ]then echo "command[check_temp]=$dir/check_temp.sh" >> $dir1/nrpe.cfgelse echo "nrpe.cfg is not exist" exit 3fiif [ -e /usr/local/nagios/bin/nrpe ]then pkill nrpe && /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -delse echo "nrpe is not exist" exit 4fi