您好,登錄后才能下訂單哦!
一、安裝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
這兩個文件默認(rèn)是不存在的,從localhost.cfg文件中復(fù)制,是用來定義你要監(jiān)控的主機(jī)和服務(wù),需要你手工創(chuàng)建。
[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后發(fā)現(xiàn)必須rewrite了
安裝pnp4nagios時使用make install-webconf
這個會在/etc/httpd/conf.d/中生成pnp4nagios.conf文件將其復(fù)制到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 //根據(jù)自身路徑設(shè)置 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、創(chuàng)建nagios登錄web用戶
[root@localhost local]# htpasswd -c /usr/local/nagios/etc/htpasswdnagiosadmin |
8、修改php目錄權(quán)限,讓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、重新加載啟動項(xiàng)
[root@localhost local]# /etc/init.d/httpd reload [root@localhostlocal]# /etc/init.d/nagios reload |
查看/usr/local/pnp4nagios/var/perfdata有沒有數(shù)據(jù) |
錯誤一:
訪問http://192.168.212.130/pnp4nagios
解決辦法:將/usr/local/pnp4nagios/share中的install.php 刪除即可
錯誤二:
解決方案:
默認(rèn)的php是root的組,而我的httpd.conf配置文件中http的用戶和組是apache
所以將php權(quán)限改為apache即可
[html] view plaincopy
1. cd /var/lib
2. chown -R apache.apache php/
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。