Control Drawing Effect(一)

发布时间:2020-08-05 21:03:29 作者:卍伪装卍
来源:网络 阅读:397

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-----
#               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] .= "LINE1:var1#FF0000:\"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#00FF00:\"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 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

Control Drawing Effect(一)




--------------------------------------------------------------------





推荐阅读:
  1. Cacti+Nagios监控平台如何整合
  2. 关于nagios的一篇很不错的文章

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

nagios pnp4nagios ct

上一篇:centos 查找不到网卡解决方法。

下一篇:Zookeeper【从五个方面,渐进】

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》