资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

监控CPU温度脚本安装

#!/bin/bash
#DATE    2013-07-09
#AUTHOR    charlie_cen
#EMAIL    cenhuqing@gmail.com
#SITE    http://charlie928.blog.51cto.com
yum clean all > /dev/null 2>&1
yum makecache > /dev/null 2>&1
if [ $? -eq 0 ]
then
        echo "yum is OK"
else
        echo "yum is wrong"
        exit 5
fi
if [ -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
        fi
fi
dir=/usr/local/nagios/libexec
cat >> $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
        done
EOF
if [ -e $dir/check_temp.sh ]
then
        chmod +x $dir/check_temp.sh
        chown nagios. $dir/check_temp.sh
else
        echo "check_temp.sh is not exist"
        exit 2
fi
dir1=/usr/local/nagios/etc
if [ -e $dir1/nrpe.cfg ]
then
        echo "command[check_temp]=$dir/check_temp.sh" >> $dir1/nrpe.cfg
else
        echo "nrpe.cfg is not exist"
        exit 3
fi
if [ -e /usr/local/nagios/bin/nrpe ]
then
        pkill nrpe && /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
else
        echo "nrpe is not exist"
        exit 4
fi

新闻名称:监控CPU温度脚本安装
分享路径:http://cdkjz.cn/article/ihihsd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220