十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
一、安装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. 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. 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. 20. |
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/