一、準備
安裝包pnp4nagios-0.6.24.tar.gz。
已經上傳至我的共享文檔中,需要的夥伴可以下載。
二、安裝
tar zxvf pnp4nagios-0.6.24.tar.gz
./configure --prefix=/usr/local/pnpnagios
make all
make install
make install-webconf
make install-config
make install-init
三、配置
3.1 pnp配置
1)修改/usr/local/pnpnagios/etc下的配置文件
cd /usr/local/pnpnagios/etc
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv rra.cfg-sample rra.cfg
2)修改/etc/pages下的配置文件 cd /usr/local/pnpnagios/etc/pages/
mv web_traffic.cfg-sample web_traffic.cfg
3)修改/etc/check_commands下的配置文件cd /usr/local/pnp4nagios/etc/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
然後service npcd start如果正確啓動說明安裝成功
3.2Nagios配置
修改etc目錄下的command.cfg配置文件,修改如下命令
define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/nagios/pnp4nagios/libexec/process_perfdata.pl
}
define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/nagios/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
注:上面的配置不能直接複製到文件中,需要將原來的命令定義註釋掉
修改/etc下的templates.cfg配置文件,修改如下
define host{
name generic-host
process_perf_data 1 ; Process performance data
action_url /pnpnagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
}
define service{
name generic-service ; The 'na
process_perf_data 1 ; Process performance data
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
}
其實就是在每一個地難以上加入action_url配置選項
重啓Nagios服務,應該可以看到在兩個主機旁邊的那個折線的小圖表
四、遇到的問題
4.1 如果點擊第三步的折線小圖標出現找不到URL的錯誤,那pnp自己產生的一個用於apache2配置的文件(/etc/httpd/conf.d/pnp4nagios.conf)內容複製到你的主apache2配置文件,我的在/usr/local/apache/conf/httpd/conf
Alias /pnpnagios "/usr/local/pnpnagios//share"
<Directory "/usr/local/pnpnagios//share">
AllowOverride None
Order allow,deny
Allow from all
#
# Use the same value as defined in nagios.conf
#
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
Options symLinksIfOwnerMatch
# Installation directory
RewriteBase /pnp4nagios/
# Protect application and system files from being viewed
RewriteRule "^(?:application|modules|system)/" - [F]
# Allow any files or directories that exist to be displayed directly
RewriteCond "%{REQUEST_FILENAME}" !-f
RewriteCond "%{REQUEST_FILENAME}" !-d
# Rewrite all other URLs to index.php/URL
RewriteRule "^.*$" "index.php/$0" [PT]
</IfModule>
</Directory>
4.2 如果遇到下面的錯誤這幾個問題暫時還沒幹掉,前輩讓我用centos 搭環境 。。。。。。。