nagios图表插件pnp4nagios

一.安装编译安装apache和php。(php版本5.2.0以上)

A.安装apache。(apache 加载rewrite模块)

[root @monitor nagios_sofo]# tar zxvf httpd-2.2.9.tar.gz
[root @monitor nagios_sofo]# cd httpd-2.2.9
[root @monitor httpd-2.2.9]# ./configure --enable-rewrite=shared --enable-module=so --enable-shared=max --prefix=/usr/local/apache
[root @monitor httpd-2.2.9]# make && make install

C。查看apache配置文件有没rewrite模块。和修改apache配置文件。

[root @monitor nagios_sofo]# vi /usr/local/apache/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
 
 
#添加支持php配置,在AddType application/x-gzip .gz .tgz下
 AddType application/x-httpd-php.php
AddType application/x-httpd-php-source.phps
 
 
#修改DirectoryIndex
 DirectoryIndex index.html index.php
 
 
#修改启动进程用户。
User nagios
Group nagios

D.如没有rewrite模块手动加载。

[root @monitor nagios_sofo]# cd httpd-2.2.9/modules/mappers/
[root @monitor mappers]# /usr/local/apache/bin/apxs -aic mod_rewrite.c
 

 

E。安装php(支持--with-zlib --with-gd模块)

[root @monitor php-5.3.10]# yum install libtool  libtool-ltdl-devel php-gd mcrypt mcrypt-devel libxml2 libxml2-devel
[root @monitor nagios_sofo]# tar zxvf php-5.3.10.tar.gz
[root @monitor nagios_sofo]# cd php-5.3.10
[root @monitor php-5.3.10]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --enable-mbstring --with-zlib --with-gd
[root @monitor php-5.3.10]#make && make install
[root @monitor php-5.3.10]# cp php.ini-development /usr/local/php/lib/php.ini
查看模块
[root @monitor nagios_sofo]# /usr/local/php/bin/php -m
zlib
gd

F.测试启动apache测试PHP。

[root @monitor nagios_sofo]# vi /usr/local/apache/htdocs/index.php
<?php
phpinfo()
?>
 
 
 
[root @monitor nagios_sofo]# /usr/local/apache/bin/apachectl -t
Syntax OK
[root @monitor nagios_sofo]# /usr/local/apache/bin/apachectl start

访问  http://ip/index.php

 

 

二。安装pnp4nagios

A.下载安装包

 http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.3.tar.gz 

http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.3.tar.gz/download


B。安装rrdtool-1.4.3.tar.gz 

wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.3.tar.gz 
yum -yinstallcairo-devel glib2-devel pango-devel
tarzxf rrdtool-1.4.3.tar.gz
cdrrdtool-1.4.3
./configure--prefix=/usr/local/rrdtool
make
makeinstall

 

C,编译安装pnp4nagios-0.6.3.tar.gz

 

wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.3.tar.gz/download
tarzxf pnp4nagios-0.6.3.tar.gz
cdpnp4nagios-0.6.3
./configure--with-rrdtool=/usr/local/rrdtool/bin/rrdtool--with-perl_lib_path=/usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi
makeall
makeinstall
makeinstall-webconf
makeinstall-config
makeinstall-init


D.配置pnp4nagios

 

 

 

cd/usr/local/pnp4nagios/etc
mvmisccommands.cfg-sample  misccommands.cfg
mvnagios.cfg-sample nagios.cfg
mvnpcd.cfg-sample npcd.cfg
mvrra.cfg-sample rra.cfg
cdpages/
mvweb_traffic.cfg-sample web_traffic.cfg
cd../check_commands
mvcheck_all_local_disks.cfg-sample  check_all_local_disks.cfg
mvcheck_nrpe.cfg-sample  check_nrpe.cfg
mvcheck_nwstat.cfg-sample  check_nwstat.cfg
 
重启服务
/etc/init.d/npcdrestart

 

E。修改nagios配置

 

修改nagios.cfg

 

vi/usr/local/nagios/etc/nagios.cfg
 
process_performance_data=1
#默认下面两行是被注释的
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata

 

 

 

修改commands.cfg

 

 

 

vim commands.cfg
#把默认两命令修改如下
 
# 'process-host-perfdata' command definition
definecommand{
       command_name   process-host-perfdata
       command_line  /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
       }
# 'process-service-perfdata' command definition
definecommand{
       command_name   process-service-perfdata
       command_line  /usr/local/pnp4nagios/libexec/process_perfdata.pl
       }

 


 

修改 templates.cfg

vim templates.cfg
## 在最后添加
define host {
name          host-pnp
action_url   /pnp4nagios/index.php/graph?host=$HOSTNAME$& 
register   0
}
define service {
name         srv-pnp
action_url   /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register   0
}

 

配置图表分析的host和service(localhost.cfg)

列如,本地主叫和远程192.168.1.232

vilocalhost.cfg
 
 
define host{
        use                     generic-host,host-pnp                                                         
        host_name               localhost
        alias                  localhost
        address                 127.0.0.1
        }
 
 
define service{
        use                             generic-service,srv-pnp       
        host_name                       localhost
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }
define service{
        use                             generic-service,srv-pnp      
        host_name                       localhost
        service_description             Root Partition
        check_command                   check_local_disk!20%!10%!/
        }
 
define service{
        use                             generic-service,srv-pnp      
        host_name                       localhost
        service_description             Current Users
        check_command                   check_local_users!20!50
        }
 
define service{
        use                             generic-service,srv-pnp      
        host_name                       localhost
        service_description             Total Processes
        check_command                   check_local_procs!250!400!RSZDT
        }
define service{
        use                             generic-service,srv-pnp       
        host_name                       localhost
        service_description             Current Load
        check_command                   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
        }
 
define service{
        use                             generic-service,srv-pnp      
        host_name                       localhost
        service_description             Swap Usage
        check_command                   check_local_swap!20!10
        }
 
define service{
        use                             generic-service,srv-pnp      
        host_name                       localhost
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
        }
define service{
        use                             generic-service,srv-pnp       
        host_name                       localhost
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }
 
 
###########################192.168.1.232
 
define host{
        use                     generic-host,host-pnp                                                                                     
        host_name               lnmp2
        alias                  LNMP_2
        address                 192.168.1.232
         hostgroups              linux-servers
        }
 
define service{
    host_name               lnmp2
     service_description     load average
     check_command           check_nrpe!check_load
     use                     generic-service,srv-pnp
              }
define service{
      host_name               lnmp2
      service_description     total-procs
       check_command           check_nrpe!check_total_procs
      use                     generic-service,srv-pnp
               }
define service{
          host_name               lnmp2
        service_description    freespace
         check_command           check_nrpe!check_disk
          use                     generic-service,srv-pnp
         }
 
 
 

windows服务器同上配置。

 

在apache添加nagios目录和pnp4nagios目录。

[root @monitor nagios_sofo]# vi /usr/local/apache/conf/httpd.conf
#添加
#nagios
ScriptAlias/nagios/cgi-bin"/usr/local/nagios/sbin/"
Alias/nagios"/usr/local/nagios/share/"
<Directory"/usr/local/nagios/sbin/">
    Options ExecCGI
    AllowOverride none
    Order allow,deny
    Allow from all
    AuthName"Nagios Access"
    AuthType Basic
    AuthUserFile/usr/local/nagios/etc/htpasswd
    Require valid-user
</Directory>
<Directory"/usr/local/nagios/share/">
    Options None
    AllowOverride none
    Order allow,deny
    Allow from all
    AuthName"Nagios Access"
    AuthType Basic
    AuthUserFile/usr/local/nagios/etc/htpasswd
    Require valid-user
</Directory>
 
 
#pnp4nagios
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
  Require valid-user
  <IfModule mod_rewrite.c>
    # Turn on URL rewriting
    RewriteEngine On
    Options FollowSymLinks
    # Installation directory
    RewriteBase/pnp4nagios/
    # Protect application and system files from being viewed
    RewriteRule ^(application|modules|system) - [F,L]
    # 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,L]
  </IfModule>
</Directory>

 

重新启动apache

/usr/local/apache/bin/apachel -t

/usr/local/apache/bin/apachel restart

重新启动nagios

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 

service nagios restart

重启npcd

service npcd restart

 

浏览器访问。http://ip/nagios

                  

 http://ip/pnp4nagios

所以要求通过。

 


修改install.php名

[root @monitor share]# mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.zoucm

 

 

 

http://ip/pnp4nagios

None 
  编辑标签

你可能感兴趣的:(pnp4nagios)