apache+nagios+pnp4nagios配置(pnp4nagios安裝配置篇)
配置pnp4nagios
下載地址:
Rrtool地址:httposs.oetiker.chrrdtool
Pnp地址:http://docs.pnp4nagios.org/
需要 rrtool 支援
yum install rrdtool gd gd-devel php-gd
安裝pnp4nagios
tar zxvf pnp4nagios-0.6.21.tar.gz cd pnp4nagios-0.6.21 ./configure
報錯
configure:error: Perl Module Time::HiRes not available
解決方法
yum installperl-Time-HiRes
make
make install
make install-config
make install-init
make install-webconf //apache伺服器需要
安裝目錄: /usr/local/pnp4nagios
建立配置檔案
cd /usr/local/pnp4nagios/etc mv misccommands.cfg-sample misccommands.cfg mv nagios.cfg-sample nagios.cfg mv rra.cfg-sample rra.cfg cd /usr/local/pnp4nagios/etc/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
重啟服務
service npcd restart
修改nagios.cfg
process_performance_data=1 //由0改為1
host_perfdata_command=process-host-perfdata //前面的註釋拿掉
service_perfdata_command=process-service-perfdata //註釋拿掉
修改commands.cfg
# 'process-host-perfdata' command definition define command{ command_name process-host-perfdata command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl }
修改配置檔案templates.cfg,新增以下內容
define host {
name hosts-pnp
register 0
action_url /pnp4nagios/graph?host=$HOSTNAME$
process_perf_data 1
}
define service {
name srv-pnp
register 0
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
修改伺服器配置檔案localhost.cfg
define host{
use linux-server,hosts-pnp
host_name localhost
alias localhost
address 127.0.0.1
}
define service{
use local-service,srv-pnp
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
配置apache
pnp4nagios4.10版本apache至此不需要做任何配置,直接就可以訪問了,升級到0.6後發現必須rewrite了
安裝pnp4nagios 時使用make install-webconf
這個會在/etc/httpd/ conf.d/中生成pnp4nagios.conf檔案將其複製到http.conf檔案中
# SAMPLE CONFIG SNIPPETS FOR APACHE WEBSERVER
Alias /pnp4nagios"/usr/local/pnp4nagios/share"
<Directory"/usr/local/pnp4nagios/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.users //根據自身配置路徑設定
Require valid-user
<IfModulemod_rewrite.c>
#Turn on URL rewriting
RewriteEngineOn
OptionssymLinksIfOwnerMatch
#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>
修改/etc/nagios/cgi.cfg裡的使用者名稱是無效的
#default_user_name=guest
設定項,取消註釋,修改為
default_user_name=nagiosadmin
重啟 nagios 和apache
service nagios restart
service httpd restart
進入後點擊小太陽出現PNP4Nagios Environment Tests
將/usr/local/pnp4nagios/share 中的install.php 刪除即可
點選小太陽出現
Please check the documentation for information about the followingerror.
session_start():open(/var/lib/php/session/sess_4m6ehg7pt0d113hvoni3es4c62, O_RDWR) failed: Permissiondenied (13)
file [line]:
/usr/local/pnp4nagios/lib/kohana/system/libraries/Session.php[159]:
Back
解決方案:
預設的php是apache的組,而我的httpd.conf中將httpd的服務改成了nagios使用者和組
所以將php許可權改為nagios 即可
cd /var/lib
chown -R nagios.nagios php/
pnp4nagios 配置成功