nagios+pnp4nagios监控

我怕爱的太早我们不能终老 提交于 2020-03-02 02:43:44
 

pnp4nagios

一、安装pnp4nagios

  预安装:rrdtoolperl-Time*

yum install rrdtool perl-Time* -y

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

  cd /usr/local/src/

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

--with-nagios-user=nagios \

--with-nagios-group=nagios

    make all

make install

make install-webconf

make install-config

make install-init

make fullinstall

二、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.

原因未知,反正可以正常使用程序。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!