ControlDrawingEffect(一)
Custom drawing templates:
[root@RHEL5 ~]# cd /usr/local/pnp4nagios/share/templates/
[root@RHEL5 templates]# vi check_cpu.php
创新互联建站企业建站,十年网站建设经验,专注于网站建设技术,精于网页设计,有多年建站和网站代运营经验,设计师为客户打造网络企业风格,提供周到的建站售前咨询和贴心的售后服务。对于网站设计制作、网站制作中不同领域进行深入了解和探索,创新互联在网站建设中充分了解客户行业的需求,以灵动的思维在网页中充分展现,通过对客户行业精准市场调研,为客户提供的解决方案。
[root@RHEL5 templates]# chown nagios:nagios *
Monitoring plugin:
[root@RHEL5 ~]# tail -n 2 /etc/nagios/resource.cfg
#Add by Kingcraft
$USER5$=/usr/local/nagios/customexec
[root@RHEL5 ~]# vi /usr/local/nagios/customexec/check_cpu.sh
#!/bin/sh #Author:zhai_kang,20131026 WARN=$2 CRIT=$4 #1 minutes load,15 minutes load Load_One=`uptime | awk -F "[:]" '{print $NF}' | awk -F "[,]" '{print $1}'` Load_Fifteen=`uptime | awk -F "[:]" '{print $NF}' | awk -F "[,]" '{print $3}'` #to obtain Max value Max=$Load_One SIGN=`echo $Max $Load_Fifteen | awk '{if($1<$2)print 1;else print 0}'` if [[ $SIGN -ge 1 ]] then Max=$Load_Fifteen fi #get return data SIGN_C=`echo $CRIT $Max | awk '{if($1<$2)print 1;else print 0}'` SIGN_W=`echo $WARN $Max | awk '{if($1<$2)print 1;else print 0}'` SIGN_O=`echo 0 $Max | awk '{if($1<$2)print 1;else print 0}'` if [[ $SIGN_C -eq 1 ]] then line=`echo "Critical : 1-Mins = $Load_One; 15-Mins = $Load_Fifteen"` RC=2 elif [[ $SIGN_W -eq 1 ]] then line=`echo "Warning : 1-Mins = $Load_One; 15-Mins = $Load_Fifteen"` RC=1 elif [[ $SIGN_O -eq 1 ]] then line=`echo "OK : 1-Mins = $Load_One; 15-Mins = $Load_Fifteen"` RC=0 else line=`echo "Unknown"` RC=3 fi echo $line \| CPU_Load=$Load_One CPU_Load=$Load_Fifteen exit $RC
Define the monitoring command:
[root@RHEL5 ~]# vi /etc/nagios/objects/commands.cfg
define command{ command_name check_cpu command_line $USER5$/check_cpu.sh -w $ARG1$ -c $ARG2$ }
Definition monitor file:
[root@RHEL5 ~]# vi /etc/nagios/Linuxhosts/localhost.cfg
define host{ use linux-server,host-pnp host_name Monitor alias Monitor address 172.17.10.4 } define service{ use local-service,srv-pnp host_name Monitor service_description check_cpu check_command check_cpu!4!6 }
Restart:
[root@RHEL5 ~]# service nagios restart
Verification:
--------------------------------------------------------------------
若在所出图像中显示Warning与Critical的警界线,则监控插件与对应的出图模板应如何改?
网页名称:ControlDrawingEffect(一)
当前地址:http://pwwzsj.com/article/jpiscp.html