您的位置:首页 > 运维架构 > Apache

apache+nagios+pnp4nagios配置(pnp4nagios安装配置篇)

2014-03-26 09:56 435 查看

配置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 配置成功

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息