nagios+pnp4nagios监控

 

pnp4nagios php

1、安装pnp4nagios ios

  预安装:rrdtoolperl-Time* web

yum install rrdtool perl-Time* -y apache

  tar -axvf pnp4nagios-0.6.4.tar.gz –C /usr/local/src/ 浏览器

  cd /usr/local/src/ 性能

    ./configure --prefix=/usr/local/pnp4nagios \ ui

--with-nagios-user=nagios \ this

--with-nagios-group=nagios url

    make all spa

make install

make install-webconf

make install-config

make install-init

make fullinstall

2、PNP4Nagios Nagios 整合

   

   建立配置文件:

cd /usr/local/pnp4nagios/etc

mv   misccommands.cfg-sample  misccommands.cfg

mv   nagios.cfg-sample nagios.cfg

mv npcd.cfg-sample npcd.cfg

mv   process_perfdata.cfg-sample process_perfdata.cfg

mv rra.cfg-sample rra.cfg

cd pages

mv   web_traffic.cfg-sampleweb_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

②修改nagios 配置文件,vi /usr/local/nagios/etc/nagios.cfg,将相应配置修改成如下内容:

process_performance_data=1

host_perfdata_command=process-host-perfdata

service_perfdata_command=process-service-perfdata

修改nagios 配置文件commands.cfg 文件中的process-host-perfdata

process-service-perfdata

# 'process-host-perfdata' command definition
define command{
       command_name   process-host-perfdata
       command_line   /usr/local/pnp4nagios/libexec/process_perfdata.pl
       }

# 'process-service-perfdata' command definition
define command{
       command_name   process-service-perfdata
       command_line   /usr/local/pnp4nagios/libexec/process_perfdata.pl
       }

④将性能图集成到nagiosweb页面,即添加小太阳模版,镶嵌在nagios页面上。

vi /usr/local/nagios/etc/objects/templates.cfg

define host{

name   host-pnp

register   0

action_url    /pnp4nagios/index.php/graph?host=$HOSTNAME$

}

define service{

name   srv-pnp

register   0

action_url    /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$

}

⑤让PNP4Nagios 显示图形在nagios 的主机中或服务中显示,加入host-pnp

srv-pnp 配置实例(注:通常只需在主机的定义(hosts.cfg)的第一行中加入:

use host-pnp便可)

例:define host {
    
 use                            host-pnp
      host_name               nagios-server

      alias                        nagios-server

      address                   10.0.0.77

      contact_groups              sagroup

      check_command             check-host-alive

      max_check_attempts        5

      notification_interval     10

      notification_period       24x7

      notification_options      d,u,r

      }

PNP4Nagios Apache 整合:

apache的配置文件httpd.conf中加上下面这行:

include conf.d/pnp4nagios.conf

⑦全部者:

chown R nagios:nagios  /usr/local/nagios

chown R nagios:nagios  /usr/local/pnp4nagios

重启服务:(便可)

         /etc/init.d/npcd   restart

       /etc/init.d/nagios       restart

常见问题:

---------------------------------------------------------------------

Starting nagios:touch: cannot touch `/usr/local/nagios/var/nagios.log': Permission denied

 done.

解决办法:权限问题,将/usr/local/nagios/var/nagios.log改成chown nagios:nagios问题解决。

---------------------------------------------------------------------

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.3 (CentOS) Server at 192.168.1.142 Port 80

解决办法:

http配置错误,与之前的配置同名了,唉!

---------------------------------------------------------------------

checking for SSL headers... configure: error: Cannot find ssl headers

解决办法:yum install openssl-devel

---------------------------------------------------------------------

经过Web访问nagios出现You don't have permission to access /nagios/ on this server提示

安装nagios后,经过web访问nagios时,浏览器提示:You don't have permission to access /nagios/ on this server 

问题分析:提示显示是没有权限,首先检测nagios配置文件,若是nagios配置文件都正确。那多是由于系统缺乏php包,我装了两次都是遇到没有php包。

解决方法:使用yum命令直接安装php包:#yum install php 

安装好后,再重启httpd命令:service httpd restart

---------------------------------------------------------------------

描述:安装好pnp4nagios后打开pnp4nagios要求你输入用户名密码,始终输入不正确。而后页出现以下错误提示Authorization Required

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

解决办法:是因为在安装pnp4nagios后在/etc/httpd/conf.d里,已经生成pnp4nagios.conf配置文件,配置文件有 AuthUserFile /usr/local/nagios/etc/htpasswd.user参数,与密码文件名一致,

致使,始终没法正确输入用户密码,修改相应的文件名就能够了。唉纠结了半天才发现。

---------------------------------------------------------------------

错误描述:登入pnp4nagios时开启php.inimagic_quotes_gpc = On,而后出现错误提示: magic_quotes_gpc is deprecated

解决办法:magic_quotes_gpc = Off

---------------------------------------------------------------------

错误描述:service nagios restart

Running configuration check...done.

Stopping nagios: done.

Starting nagios:su: warning: cannot change directory to /dev/null: Not a directory

This account is currently not available.

缘由未知,反正能够正常使用程序。