Custom drawing templates:
[root@RHEL5 ~]# cd /usr/local/pnp4nagios/share/templates/
[root@RHEL5 templates]# vi check_cpu.php
<?php #-----The Color of The Three Primary Colors----- $colors = array( 'red' => '#FF0000', 'green' => '#00FF00', 'blue' => '#0000FF', 'yellow' => '#FFFF00', 'black' => '#000000', 'deepred' => '#330000', ); #------------------Image Title------------------ $opt[1] = "--title \"CPU_Load For $hostname / $servicedesc\" "; #-------------1 Minutes Average Load------------ $def[1] = "DEF:var1=$RRDFILE[1]:$DS[1]:AVERAGE " ; $def[1] .= "HRULE:$WARN[1]#00FF00 "; $def[1] .= "HRULE:$CRIT[1]#FF0000 "; $def[1] .= "LINE1:var1#0000FF:\"1-Mins \" " ; $def[1] .= "GPRINT:var1:MIN:\"%3.4lg %s$UNIT[1] Min \\t\" "; $def[1] .= "GPRINT:var1:MAX:\"%3.4lg %s$UNIT[1] Max \\t\" "; $def[1] .= "GPRINT:var1:AVERAGE:\"%3.4lg %s$UNIT[1] Average \\n\" "; #-------------15 Minutes Average Load----------- $def[1] .= "DEF:var2=$RRDFILE[2]:$DS[2]:AVERAGE " ; $def[1] .= "LINE2:var2$colors[black]:\"15-Mins \" " ; $def[1] .= "GPRINT:var2:MIN:\"%3.4lg Min \\t\" "; $def[1] .= "GPRINT:var2:MAX:\"%3.4lg Max \\t\" "; $def[1] .= "GPRINT:var2:AVERAGE:\"%3.4lg Average \\n\" "; ?>
[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;$WARN;$CRIT" 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!2!3 }
Restart:
[root@RHEL5 ~]# service nagios restart
Verification:
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
本文題目:ControlDrawingEffect(二)-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://jinyejixie.com/article46/dhcohg.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設、服務器托管、網(wǎng)站設計、ChatGPT、手機網(wǎng)站建設、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容