您好,登录后才能下订单哦!
一、安装pnp4nagios
官方的安装文档(http://docs.pnp4nagios.org/pnp-0.6/doc_complete)
1、安装
[root@localhost src]# wget http://jaist.dl.sourceforge.net/ ...agios-0.6.22.tar.gz --prefix=/usr/local/pnp4nagios --with-nagios-user=nagios--with-nagios-group=nagios \ --with-nagios-group=nagios--with-rrdtool=/usr/local/rrdtool/bin/rrdtool //rrdtool为源码安装 [root@localhost pnp4nagios-0.6.22]# make all |
2、修改nagios.cfg
[root@localhost etc]# vim /usr/local/nagios/etc/nagios.cfg 修改如下 process_performance_data=1 service_perfdata_command=process-service-perfdata host_perfdata_command=process-host-perfdata |
3、修改nagios command配置文件
[root@localhost bin]# cd /usr/local/nagios/etc/objects [root@localhostobjects]# vim commands.cfg (在文件末尾追加如下几行,删除原来的) definecommand { command_name process-service-perfdata command_line /usr/bin/perl/usr/local/pnp4nagios/libexec/process_perfdata.pl } definecommand { command_name process-host-perfdata command_line /usr/bin/perl/usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA } |
4、修改nagios template 配置文件
[root@localhost objects]# vim /usr/local/nagios/etc/objects/templates.cfg (在文件末尾追加如下几行) definehost { name host-pnp action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_ register 0 } defineservice { name service-pnp action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ register 0 } |
5、修改 hosts.cfg 和 services.cfg
这两个文件默认是不存在的,从localhost.cfg文件中复制,是用来定义你要监控的主机和服务,需要你手工创建。
[root@localhost objects]# vim hosts.cfg definehost{ use linux-server,host-pnp host_name web01 alias pub_web01 address 192.168.0.51 } definehost{ use linux-server,host-pnp host_name oracle alias pub_oracle address 192.168.0.180 } |
[root@localhost objects]# vim services.cfg |
测试nagios配置文件是否正确
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg |
6、apache与pnp整合
pnp4nagios4.10版本apache至此不需要做任何配置,直接就可以访问了,升级到0.6后发现必须rewrite了
安装pnp4nagios时使用make install-webconf
这个会在/etc/httpd/conf.d/中生成pnp4nagios.conf文件将其复制到http.conf文件中
vim /etc/httpd/conf/httpd.conf 最后空白处添加: 1. Alias /pnp4nagios "/usr/local/pnp4nagios/share" 2. 3. <Directory "/usr/local/pnp4nagios/share"> 4. AllowOverride None 5. Order allow,deny 6. Allow from all 7. AuthName "Nagios Access" 8. AuthType Basic 9. AuthUserFile /usr/local/nagios/etc/htpasswd //根据自身路径设置 10. Require valid-user 11. <IfModule mod_rewrite.c> 12. RewriteEngine On 13. Options FollowSymLinks 14. RewriteBase /pnp4nagios/ 15. RewriteRule ^(application|modules|system) - [F,L] 16. RewriteCond %{REQUEST_FILENAME} !-f 17. RewriteCond %{REQUEST_FILENAME} !-d 18. RewriteRule .* index.php/$0 [PT,L] 19. </IfModule> 20.</Directory> |
7、创建nagios登录web用户
[root@localhost local]# htpasswd -c /usr/local/nagios/etc/htpasswdnagiosadmin |
8、修改php目录权限,让apache支持pnp
[root@localhost local]# chown -R apache.apache /var/lib/php/ |
9、删除install.php文件
[root@localhost local]# rm -f /usr/local/pnp4nagios/share/install.php |
10、重新加载启动项
[root@localhost local]# /etc/init.d/httpd reload [root@localhostlocal]# /etc/init.d/nagios reload |
查看/usr/local/pnp4nagios/var/perfdata有没有数据 |
错误一:
访问http://192.168.212.130/pnp4nagios
解决办法:将/usr/local/pnp4nagios/share中的install.php 删除即可
错误二:
解决方案:
默认的php是root的组,而我的httpd.conf配置文件中http的用户和组是apache
所以将php权限改为apache即可
[html] view plaincopy
1. cd /var/lib
2. chown -R apache.apache php/
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。