Nagios结合pnp4nagios图形监控

nagios的安装及配置在以下文章里面

http://bbotte.blog.51cto.com/6205307/1403997

http://bbotte.blog.51cto.com/6205307/1543832 


版本说明:系统CentOS6.5 64位  nagios-4.0.5 nagios-plugins-2.0 nrpe-2.15 pnp4nagios-0.6.24 rrdtool-1.4.9


nagios服务已经安装完成,下面先安装rrdtoolhttp://oss.oetiker.ch/rrdtool/ 

yum install  libjpeg-devel libpng-devel pango* libart_lgpl-devel pango-devel* cairo-devel* libxml2-devel libjpeg-devel libpng-devel php-gd gd-devel perl-GD libtoul-ltdl-devel rrdtool-perl perl-devel perl-ExtUtils-Embed perl-Time-HiRes

tar -xzf rrdtool-1.4.9.tar.gz 

cd rrdtool-1.4.9

./configure –prefix=/usr/local/rrdtool

make

make install

cd ..

安装pnp4nagios http://www.pnp4nagios.org/

tar -xzf pnp4nagios-0.6.24.tar.gz 
cd pnp4nagios-0.6.24
ls /usr/local/pnp
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool
make all
make install 
make install-webconf  
make install-config  
make install-init
 
cd /usr/local/pnp4nagios/etc/ 
cp rra.cfg-sample rra.cfg

#PNP的五种模式 Synchronous Mode、Bulk Mode、Bulk Mode with NPCD、Bulk Mode with npcdmod、Gearman Mode http://docs.pnp4nagios.org/pnp-0.6/modes   

Nagios结合pnp4nagios图形监控

#下面是Bulk Mode with NPCD模式配置

cd /usr/local/nagios/etc/objects/

vim commands.cfg
# 'process-host-perfdata' command definition
#注释默认的process-host-perfdata和process-service-perfdata,添加以下
define command{
 command_name process-service-perfdata-file
 command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$
 }

define command{
 command_name process-host-perfdata-file
 command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
 }

#启动npcd服务

/usr/local/pnp4nagios/bin/npcd -d -f /usr/local/pnp4nagios/etc/npcd.cfg

  

vim /usr/local/nagios/etc/nagios.cfg
process_performance_data=1  
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata  
service_perfdata_file_template=DATATYPE::SERVICEPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tSERVICEDESC::$SERVICEDESC$tSERVICEPERFDATA::$SERVICEPERFDATA$tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$tHOSTSTATE::$HOSTSTATE$tHOSTSTATETYPE::$HOSTSTATETYPE$tSERVICESTATE::$SERVICESTATE$tSERVICESTATETYPE::$SERVICESTATETYPE$  
service_perfdata_file_mode=a  
service_perfdata_file_processing_interval=15  
service_perfdata_file_processing_command=process-service-perfdata-file 
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata  
host_perfdata_file_template=DATATYPE::HOSTPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tHOSTPERFDATA::$HOSTPERFDATA$tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$tHOSTSTATE::$HOSTSTATE$tHOSTSTATETYPE::$HOSTSTATETYPE$  
host_perfdata_file_mode=a  
host_perfdata_file_processing_interval=15  
host_perfdata_file_processing_command=process-host-perfdata-file

  

vim localhost.cfg 
 define host{
        use                     linux-server,host-pnp #修改这里
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }
define service{
        use                             local-service,service-pnp #需要画图的都加上service-pnp      
        host_name                       localhost
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }
vim templates.cfg
define host{
        name       host-pnp
        register   0
        action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_
        process_perf_data 1
        }
define service{
        name       service-pnp
        register   0
        action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ 
        process_perf_data 1
        }

配置完成,检查nagios配置后将nagios和apache重启

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

service nagios restart

service httpd restart


Nagios结合pnp4nagios图形监控

出现这个页面说明安装完成,那么将install.php删除后刷新即可看到出图的页面

mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.bak

如下:

Nagios结合pnp4nagios图形监控

如果需要在nagios页面即可查看到动态曲线那么需要做如下改动:

Nagios结合pnp4nagios图形监控

到pnp4nagios-0.6.24解压目录下

cp pnp4nagios-0.6.24/contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/

vim /usr/local/nagios/etc/objects/templates.cfg 
define host{
        name       host-pnp
        register   0
        action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$&srv=_HOST_
        process_perf_data 1
        }
define service{
        name       service-pnp
        register   0
        action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$&srv=$SERVICEDESC$  
        process_perf_data 1
        }

备注:

生成的rrd文件在此目录/usr/local/pnp4nagios/var/perfdata/localhost

Nagios结合pnp4nagios图形监控

如果因为网络不稳定导致出图问题,可以修改一下超时时间

vim /usr/local/pnp4nagios/etc/process_perfdata.cfg

TIMEOUT = 30  #默认是15秒

参考:http://www.ttlsa.com/nagios/7-nagios-install-pnp4nagios/

文章版权声明

 1 原创文章作者:Dada,如若转载,请注明出处: https://www.52hwl.com/34376.html

 2 温馨提示:软件侵权请联系469472785#qq.com(三天内删除相关链接)资源失效请留言反馈

 3 下载提示:如遇蓝奏云无法访问,请修改lanzous(把s修改成x)

 免责声明:本站为个人博客,所有软件信息均来自网络 修改版软件,加群广告提示为修改者自留,非本站信息,注意鉴别

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023年7月15日 下午12:26
下一篇 2023年7月15日 下午12:26