nagios安装PNP
注:本文是借鉴网上资料修改而来,写的不是很仔细,错误之处请自行改正。
[PNP是一个基于php和perl,用rrdtool将nagios采集的数据绘制图表的工具,所以安装pnp之前必须先安装php perl and rrdtool这里用yum直接来安装rrdtool,单独下载安装有很多依存关系,挺麻烦.]
1.安装rrdtool
wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.18.tar.gz/download# tar zxvf pnp4nagios-0.6.18# cd pnp4nagios-0.6.18./configure --with-nagios-user=nagios --with-nagios-group-nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata# make all# make install# make install-config# make install-init
配置Nagios来启用PNP
# cd /usr/local/nagios/etc/# vim nagios.cfgenable_environment_macros=1默认是开启了的host_perfdata_command=process-host-perfdata #去掉注释service_perfdata_command=process-service-perfdata
pnp4nagios有很多种工作模式,这里我们选用同步模式,想选其它模式可以看说明都有详细配置教程(不同模式配置不同)
[这里先把pnp4nagios执行数据收集的文件拷贝到nagios的libexec下,方便统一命令的执行路径.]
cp /usr/local/pnp4nagios/libexec/process_perfdata.pl /usr/local/nagios/libexec/
然后在commands.cfg里面加入如下(这里是同步模式设定方法)
# cd /usr/local/nagios/etc/objects/# vim commands.cfg#process-host-perfdata' command definitiondefine command{command_name process-host-perfdatacommand_line $USER1$/process_perfdata.pl -d HOSTPERFDATA}#process-service-perfdata' command definitiondefine command{command_name process-service-perfdatacommand_line $USER1$/process_perfdata.pl}
然后添加小太阳模版,镶嵌在nagios页面上
[这里有两种查看图的方法,第一种方法是你当太阳的图标的时候会在新窗口中打开图形查看,第二种方法是你只需要把鼠标移动到太阳图标上面就会自动弹出图形出来,以下两种方法你可以根据自己喜好选其中一种即可]第一种方法在templates.cfg里面加入如下
define host {name hosts-pnpaction_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_register 0}define service {name srv-pnpaction_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$register 0}
第二种方法按照说明加入如下
拷贝status-header.ssi到/usr/local/nagios/share/ssi/目录下面来(这一步很重要,要不然移动到太阳标记上出不来图)
cp /home/soft/pnp4nagios-0.6.18/contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/define host {name hosts-pnpaction_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_register 0}define service { name services-pnpaction_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips'rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$register 0}
第二种方法最终效果图
为目标主机图标旁边添加一个小太阳标记
define host{use linux-server,hosts-pnphost_name webalias webaddress 192.168.1.11}
为相关服务添加一个小太阳标记
# vim services.cfgdefine service{use services-pnphost_name webservice_description check-host-alivecheck_command check-host-alive}
先做一下pnp4nagios环境测试,
# vim /etc/httpd/conf/httpd.conf
修改apache配置文件在末尾加入
Alias /pnp4nagios "/usr/local/pnp4nagios/share"AllowOverride NoneOrder allow,denyAllow from allAuthName "Nagios Access"AuthType BasicAuthUserFile /usr/local/nagios/etc/htpasswd.usersRequire valid-user RewriteEngine OnOptions FollowSymLinksRewriteBase /pnp4nagios/RewriteRule ^(application|modules|system) - [F,L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule .* index.php/$0 [PT,L]
访问
查看pnp4配置是否正确,
然后
按要求重命名install.php
#mv install.php install.php.bak
做好相关配置以后请用命令重启一下nagios的服务
#checknagios 检测nagios配置文件#service nagios restartOk,
如果这篇文章帮助到了你,请不要吝啬你的回复!