nagios圖像(pnp4nagios)
http://cdnetworks-kr-1.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.6.tar.gz
http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rrdtool-1.2.18-1.el5.rf.i386.rpm (32位)
http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/perl-rrdtool-1.2.18-1.el5.rf.i386.rpm
http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rrdtool-1.2.18-1.el5.rf.x86_64.rpm (64位)
http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/perl-rrdtool-1.2.18-1.el5.rf.x86_64.rpm
# rpm -ivh rrdtool-1.2.18-1.el5.rf.i386.rpm
# rpm -ivh perl-rrdtool-1.2.18-1.el5.rf.i386.rpm
# tar zxvf pnp4nagios-0.6.6.tar.gz
# cd pnp4nagios-0.6.6
# /configure --with-nagios-user=nagios --with-nagios-group=nagios
# make all
# make install
# make install-config
# make install-init
# mv sample-config/httpd.conf sample-config/nagiosweb.conf
# cp sample-config/nagiosweb.conf /usr/local/apache/conf
# vi /usr/local/apache/conf/nagiosweb.conf
AuthType /usr/local/nagios/etc/htpasswd (原爲AuthType /usr/local/nagios/etc/htpasswd.users)
:wq
# vi /usr/local/apache/conf/httpd.conf
Include conf/nagiosweb.conf
:wq
# service httpd restart
注:原只需make install-webconf即可,但我執行沒成功,只好這麼做了,效果是一樣的
# cd /usr/local/pnp4nagios/etc
# mv misccommands.cfg-sample misccommands.cfg
# mv nagios.cfg-sample nagios.cfg
# mv npcd.cfg-sample npcd.cfg
# mv process_perfdata.cfg-sample process_perfdata.cfg
# mv rra.cfg-sample rra.cfg
# cd pages
# mv web_traffic.cfg-sample web_traffic.cfg
# cd ../check_commands
# mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
# mv check_nrpe.cfg-sample check_nrpe.cfg
# mv check_nwstat.cfg-sample check_nwstat.cfg
啓動npcd服務
# service npcd start
開機自啓動npcd
# chkconfig --add npcd
# chkconfig --level 35 npcd on
# vi /usr/local/nagios/etc/nagios.cfg (把前面的註釋符"#"去掉)
process_performance_data=1 (原爲process_performance_data=0)
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
:wq
# vi /usr/local/nagios/etc/objects/commands.cfg
# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
:wq
注:要註釋掉原有對process-service-perfdata和process-host-perfdata的定義
爲主機添加小太陽圖標
# vi /usr/local/nagios/etc/objects/yang.cfg
define host {
use linux-server
host_name yang
address 192.168.1.10
action_url /pnp4nagios/graph?host=$HOSTNAME$
}
:wq
爲單個服務添加小太陽圖標
# vi /usr/local/nagios/etc/objects/yang.cfg
define service {
use generic-service
host_name yang
service_description check_load
check_command check_nrpe!check_load
normal_check_interval 2
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
}
:wq
重啓 nagios 服務
# /etc/init.d/nagios restart
# vi /usr/local/php/etc/php.ini
magic_quotes_gpc = off (原爲magic_quotes_gpc = on)
:wq
# service httpd restart
# mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install2.php (或者直接刪除)
注:點擊小太陽圖標後會出現個測試頁面,各項要求都PASS了,會提示你重命名或刪除install.php文件,原因不詳
# ls /usr/local/pnp4nagios/var/perfdata (看下面有沒有nagios中定義的主機名目錄以及目錄下面有沒有對應服務的rrd文件和xml文件)
注:nagio圖像(pnp4nagios)只能顯示nagios插件中的服務,以腳本監控的服務不顯示圖像