189 8069 5689

Customplug(一)-创新互联

Monitoring plugin:

成都创新互联公司拥有一支富有激情的企业网站制作团队,在互联网网站建设行业深耕十余年,专业且经验丰富。十余年网站优化营销经验,我们已为上千多家中小企业提供了成都网站设计、成都做网站解决方案,按需定制设计,设计满意,售后服务无忧。所有客户皆提供一年免费网站维护!

[root@RHEL5 ~]# cd /usr/local/nagios/
[root@RHEL5 nagios]# mkdir customexec
[root@RHEL5 nagios]# vi customexec/check_procs.sh

#!/bin/sh
#Author:zhai_kang,20131024
COUNT=`ps -ef | grep -v grep | grep $2 | wc -l`
PROC=`expr $COUNT - 2`
if [[ $PROC -ge $6 ]]
then
        line=`echo "Critical - PROC=$PROC"`
        RC=2
elif [[ $PROC -ge $4 ]]
then
        line=`echo "Warning - PROC=$PROC"`
        RC=1
elif [[ $PROC -ge 1 ]]
then
        line=`echo "OK - PROC=$PROC"`
        RC=0
else
        line=`echo "Unknown - PROC=null"`
        RC=3
fi
echo $line \| proc=$PROC
exit $RC

[root@RHEL5 nagios]# chown -R nagios:nagios customexec/
[root@RHEL5 nagios]# chmod +x customexec/check_procs.sh

Set the path to the plugins:
[root@RHEL5 nagios]# vi /etc/nagios/resource.cfg

#Add by Kingcraft
$USER5$=/usr/local/nagios/customexec

Integration of the PNP4Nagios and Nagios:
[root@RHEL5 nagios]# vi /etc/nagios/nagios.cfg

process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata

[root@RHEL5 nagios]# vi /etc/nagios/objects/templates.cfg

#Add by Kingcraft
define host{
    name            host-pnp
    register        0
    action_url      /pnp4nagios/graph?host=$HOSTNAME$
    }
define service{
    name            srv-pnp
    register        0
    action_url      /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
    }

Define the monitoring command:
[root@RHEL5 nagios]# vi /etc/nagios/objects/commands.cfg

define command{
    command_name   process-host-perfdata
    command_line   /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
define command{
    command_name   process-service-perfdata
    command_line      /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
define command{
        command_name    check_procs
        command_line    $USER5$/check_procs.sh -a $ARG1$ -w $ARG2$ -c $ARG3$
        }

Definition monitor file:
[root@RHEL5 nagios]# vi /etc/nagios/Linuxhosts/localhost.cfg

# Define a host for the local machine
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_procs
        check_command           check_procs!ndo2db!4!6
        }

Syntax checking && restart nagios:
[root@RHEL5 nagios]# /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg
[root@RHEL5 nagios]# service nagios restart

Verification:

Custom plug(一)

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享题目:Customplug(一)-创新互联
网页链接:http://cdxtjz.cn/article/igsdh.html

其他资讯