开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvis(三)pnp4nagios安装
官网地址:https://docs.pnp4nagios.org/
创新互联建站专业为企业提供雄县网站建设、雄县做网站、雄县网站设计、雄县网站制作等企业网站建设、网页设计与制作、雄县企业网站模板建站服务,十载雄县做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
前面的文章已经说过,pnp4nagios的Broker模式不支持nagios4x,这里采用Bulk Mode模式
1.RRDtool的安装,这里使用的是yum安装
#yum install -y rrdtool*
2.pnp4nagios安装
#tar -zxvf pnp4nagios-0.6.25.tar.gz
#cd pnp4nagios-0.6.25
#./configure --with-rrdtool=/usr/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata --with-perfdata-spool-dir=/usr/local/nagios/share/spool --with-nagios-user=nagios --with-nagios-group=nagios
#make all
#make install
#make install-config
#make install-init
3.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
4.修改相关配置文件
(1)修改templates.cfg,增加一个定义PNP的host和service
define host {
name host-pnp
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
process_perf_data 1
}
define service {
name srv-pnp
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
(2)修改nagios.cfg
process_performance_data=1
enable_environment_macros=1
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$\tSERVICEOUTPUT::$SERVICEOUTPUT$
host_perfdata_file_mode=a
service_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
service_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
service_perfdata_file_processing_command=process-service-perfdata-file
(3)修改commands.cfg
增加如下配置
define command{
command_name process-service-perfdata-file
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/service-perfdata
}
define command{
command_name process-host-perfdata-file
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/host-perfdata
}
(4)修改host和service的模版
define host{
name gchost
use host-pnp
max_check_attempts 1
normal_check_interval 2
retry_check_interval 1
check_period 24x7
contact_groups myself_group
notification_interval 2
notification_period 24x7
notification_options d,u,r
check_command check-host-alive
}
define service{
name myself_temp
use srv-pnp
max_check_attempts 2
normal_check_interval 2
retry_check_interval 1
check_period 24x7
notification_interval 2
notification_period 24x7
notification_options w,u,c,r
contact_groups myself_group
check_command check-host-alive
register 0
}
(5)apache配置
#vim /etc/httpd/conf/httpd.conf
Alias /pnp4nagios "/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
#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]
(6)复制鼠标悬停图标显示
cp /usr/local/src/pnp4nagios-0.6.25/contrib/ssi/* /usr/local/nagios/share/ssi/
到这里就可以检测nagios配置文件无误后重启nagios观看效果
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#/etc/init.d/nagios restart
#/etc/init.d/httpd restart
附上nagios启动之后可能会遇到的问题以及解决办法以供参考
1.点击图标按钮如果出现如下提示,执行
#rm -rf /usr/local/pnp4nagios/share/install.php
2.点击图标按钮如果出现如下提示,执行
#chown -R tong:tong /var/lib/php
当前名称:开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvis(三)pnp4nagios安装
网站路径:http://scyanting.com/article/gjpsjh.html