NAGIOS插件pnp4nagios安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NAGIOS插件pnp4nagios安装相关的知识,希望对你有一定的参考价值。

NAGios插件pnp4nagios安装
注:nagios版本nagios4.0.8

1.下载安装 pnp4nagios-0.6.25.tar.gz

wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.25.tar.gz

yum -y install rrdtool perl-Time-HiRes perl-File-Tail rrdtool rrdtool-perl php-gd

tar zxvf? pnp4nagios-0.6.25.tar.gz

cd pnp4nagios-0.6.25

#perl -MRRDs -le ‘print q(ok!)‘
如果返回值是ok!,则可以进行pnp4nagios配置和安装
#./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/bin/rrdtool?--with-perl_lib_path=/usr/lib64/perl5/vendor_perl/auto/RRDs
#make all
#make install
#make install-webconf
#make install-config
#make install-init

2.创建配置文件

cd /usr/local/pnp4nagios/etc

mv misccommands.cfg-sample? misccommands.cfg

mv nagios.cfg-sample? nagios.cfg

mv npcd.cfg-sample npcd.cfg

mv process_perfdata.cfg-sample? process_perfdata.cfg

#?mv rra.cfg-sample rra.cfg

#? cd pages

mv web_traffic.cfg-sample web_traffic.cfg

cd ../check_commands

mv check_all_local_disks.cfg-sample? check_all_local_disks.cfg

mv check_nrpe.cfg-sample? check_nrpe.cfg

mv check_nwstat.cfg-sample? check_nwstat.cfg

  1. 重启服务

    /etc/init.d/npcd restart

    echo “/etc/init.d/npcd start”>>/etc/rc.local
    4.修改 nagios 的配置文件.打开performance_data

    cd /usr/local/nagios/etc

    vim nagios.cfg

    #打开注释项:
    process_performance_data=1
    host_perfdata_command=process-host-perfdata
    service_perfdata_command=process-service-perfdata
    #######################添加如下内容####################################
    service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
    service_perfdata_file_template=DATATYPE::SERVICEPERFDATA TIMET::$TIMET$ HOSTNAME::$HOSTNAME$ SERVICEDESC::$SERVICEDESC$ SERVICEPERFDATA::$SERVICEPERFDATA$ SERVICEC::HECKCOMMAND::$SERVICECHECKCOMMAND$ HOSTSTATE::$HOSTSTATE$ HOSTSTATETYPE::$HOSTSTATETYPE$ SERVICESTATE::$SERVICESTATE$ SERVICESTATETYPE::$SERVICESTATETYPE$
    service_perfdata_file_mode=a
    service_perfdata_file_processing_interval=15
    service_perfdata_file_processing_command=process-service-perfdata-file

    host performancedata starting with Nagios 3.0

    host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
    host_perfdata_file_template=DATATYPE::HOSTPERFDATA TIMET::$TIMET$ HOSTNAME::$HOSTNAME$ HOSTPERFDATA::$HOSTPERFDATA$ HOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$ HOSTSTATE::$HOSTSTATE$ HOSTSTATETYPE::$HOSTSTATETYPE$
    host_perfdata_file_mode=a
    host_perfdata_file_processing_interval=15
    host_perfdata_file_processing_command=process-host-perfdata-file
    ###########################################################
    5.修改 commands.cfg

    cd /usr/local/nagios/etc/objects

    vim commands.cfg

    ##添加
    #################################################################
    define command{
    command_name process-service-perfdata
    command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/service-perfdata
    }

define command{
command_name process-host-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/host-perfdata
}

  1. 添加小太阳模版,镶嵌在nagios页面上。

    vim templates.cfg

    在最后添加

    define host {
    name host-pnp
    action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=HOST
    register 0
    }
    define service {
    name srv-pnp
    action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
    register 0
    }
    7,修改 hosts.cfg 和services.cfg

    cd /usr/local/nagios/etc/objects

    #修改hosts.cfg

    vim hosts.cfg

    define host{
    ????????use???????????????????? linux-server,host-pnp??
    ????????host_name????????? wwwserver
    ????????alias???????????????????? wwwserver
    ????????address????????????????? 10.10.10.111
    ????????}

修改 services.cfg

define service{
????????use???????????????????????? ?local-service,srv-pnp??????
????????host_name?????????????????? ?wwwserver
????????service_description???????? PING
????????check_command???????????? check_ping!100.0,20%!500.0,60%
}
其他的主机和服务以此类推
检查配置文件正确与否
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

返回值如上图片,则重启nagios
8.重启?nagios?服务
#/etc/init.d/nagios restart
效果图:
技术分享图片
这时点击小太阳会出现如下提示:The requested URL /pnp4nagios/graph was not found on this server.
解决方法如下:
原因,当你在pnp4nagios安装的时候执行了make install-webconf,注意它生成了一个apache的配置文件。
你把这个文件:/etc/httpd/conf.d/pnp4nagios.conf?中的所有内容全部添加到apache的httpd.conf文件最后,再重新启动nagios和apache就应该可以啦。

[[email protected] etc]# find / -name pnp4nagios.conf
/etc/httpd/conf.d/pnp4nagios.conf
[[email protected] etc]# vim /etc/httpd/conf.d/pnp4nagios.conf
[[email protected] etc]# cat /etc/httpd/conf.d/pnp4nagios.conf>>/usr/local/apache/conf/httpd.conf
#service httpd restart
#service Nagios restart
这时再点击小太阳,会出现pnp4nagios的测试页,结果如下:

告诉要删掉或重命名/usr/local/pnp4nagios/share/install.php
故障2:
安装测试:
http://monitor.dreamlive.tv//pnp4nagios/index.php

#cd /usr/local/pnp4nagios/share
#mv install.php install.php.bak
在此测试:显示如下:

没有图像出现,主要原因就是:导致
解决方法:

改为:

重启httpd
结果就正常了

报如下错误

Yum -y install pango pango-devel
然后重启系统

以上是关于NAGIOS插件pnp4nagios安装的主要内容,如果未能解决你的问题,请参考以下文章

linux系统管理员之自动化检测工具 nagios及其插件配置

为nagios装上pnp4nagios功能

开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvisnagios+cacti整合

Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvisnagios安装

pnp4nagios的安装

开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvispnp4nagios安装