q4561231 发表于 2019-1-9 13:20:05

开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvis(三)pnp4nagios安装

  官网地址:https://docs.pnp4nagios.org/
  

  前面的文章已经说过,pnp4nagios的Broker模式不支持nagios4x,这里采用Bulk Mode模式
  http://s3.运维网.com/wyfs02/M00/7C/79/wKioL1bRPHbzHBuRAACgCAbUe2A289.png
  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-samplemisccommands.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-samplecheck_all_local_disks.cfg
mv check_nrpe.cfg-samplecheck_nrpe.cfg
mv check_nwstat.cfg-samplecheck_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_interval2
      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)/" -
                   #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"
         


(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
  http://s1.运维网.com/wyfs02/M00/7C/7B/wKiom1bRPajgXnlLAAB9iQtjcOU838.png
  

  2.点击图标按钮如果出现如下提示,执行
  #chown -R tong:tong/var/lib/php
  http://s3.运维网.com/wyfs02/M02/7C/7B/wKiom1bRPcyDzEqwAABUTHoBsR4336.png
  




页: [1]
查看完整版本: 开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvis(三)pnp4nagios安装