煮酒品茶:好久之前写的文章,放在论坛里,取出来共享之。

Repost:http://deidara.blog.51cto.com/400447/382129

官方文档网站:http://docs.pnp4nagios.org/pnp-0.4/start

1.下载安装 pnp4nagios-0.6.6.tar.gz

wget http://jaist.dl.sourceforge.net/project … .19.tar.gz
yum install rrdtool librrds-perl
tar zxvf  pnp4nagios-0.6.6.tar.gz
cd pnp4nagios-0.6.6
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make all
make install
make install-webconf
make install-config
make install-init

2.创建配置文件

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-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

3. 重启服务

/etc/init.d/npcd restart

4.修改 nagios 的配置文件.打开performance_data

cd /usr/local/nagios/etc

vim nagios.cfg
#打开注视项:

process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata

5.编译 commands.cfg

cd /usr/local/nagios/etc/objects
vim commands.cfg

##添加

# '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
       }

6. 添加小太阳模版,镶嵌在nagios页面上。
vim templates.cfg
## 在最后添加

define host {
name       host-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_
register   0
}
define service {
name       srv-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register   0
}

7,修改 hosts.cfg 和  色services.cfg
cd /usr/local/nagios/etc/eric.com
#修改hosts.cfg
vim hosts.cfg

define host{
       use                     linux-server,host-pnp  
       host_name         eric.com
       alias                     eric.com
       address                 192.168.6.101
       }

# 修改 services.cfg

define service{
       use                                     local-service,srv-pnp      
       host_name                       eric.com
       service_description        PING
       check_command            check_ping!100.0,20%!500.0,60%
}

8.重启 nagios 服务

/etc/init.d/nagios restart

效果图:
nagios安装配置pnp4nagios-0.6_第1张图片

品茶:文章是比较老的版本,所以用新的版本会有不同的点。
环境:

OS            centos5.8 64bit
nagios        nagios3.5
pnp4nagios    pnp4nagios-0.6.19

1、/usr/local/pnp4nagios/share/install.php #此为http://ip/pnp4nagios的监测环境页面,测试通过就删除页install.php文件。

PNP4Nagios Environment Tests
PNP4Nagios Version    pnp4nagios-0.6.19
Prefix    /usr/local/pnp4nagios
Configure Arguments    ./configure '--with-rrdtool=/usr/bin/rrdtool'
RRD Storage    /usr/local/pnp4nagios/var/perfdata is readable.
RRDtool Binary    /usr/bin/rrdtool is executable by PHP
PHP GD extension    Pass
PHP function proc_open()    Pass
PHP zlib extension    Pass
PHP session extension    Pass
PHP JSON extension    Pass
PHP magic_quotes_gpc    Off
PHP socket extension    Pass
Apache Rewrite Module    Pass

PHP Version    5.1.6
System Directory    /usr/local/pnp4nagios/lib/kohana/system/
Application Directory    /usr/local/pnp4nagios/share/application/
Reflection Enabled    Pass
Iconv Extension Loaded    Pass
URI Determination    Pass

Your environment passed all requirements. Remove or rename the /usr/local/pnp4nagios/share/install.php file now.

2、在command.cfg文件里,默认是有两段定义的command_name,所以得先注释。

# 'process-host-perfdata' command definition
#define command{
#       command_name    process-host-perfdata
#       command_line    /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out
#       }


# 'process-service-perfdata' command definition
#define command{
#       command_name    process-service-perfdata
#       command_line    /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out
#       }

3、在创建默认文件名时,有些文件名是不同的。

[root@KTQT objects]# tree /usr/local/pnp4nagios/etc/
/usr/local/pnp4nagios/etc/
|-- background.pdf
|-- check_commands
|   |-- check_all_local_disks.cfg
|   |-- check_all_local_disks.cfg-sample
|   |-- check_nrpe.cfg
|   |-- check_nrpe.cfg-sample
|   |-- check_nwstat.cfg
|   `-- check_nwstat.cfg-sample
|-- config.d
|-- config.php
|-- config.php.0.6.19
|-- config_local.php
|-- misccommands.cfg
|-- misccommands.cfg-sample
|-- nagios.cfg
|-- nagios.cfg-sample
|-- npcd.cfg
|-- npcd.cfg.0.6.19
|-- npcd.cfg.old
|-- pages
|   |-- web_traffic.cfg
|   `-- web_traffic.cfg-sample
|-- pnp4nagios_release
|-- process_perfdata.cfg
|-- process_perfdata.cfg.0.6.19
|-- process_perfdata.cfg.old
|-- rra.cfg
`-- rra.cfg-sample

3 directories, 25 files

4、依赖于以下组件,并更改源。

http php php-gd nagios rrdtool

[root@cwtea yum.repos.d]# cat dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
[root@cwtea yum.repos.d]# yum install rrdtool php-gd

5、command.cfg文件process-host-perfdata command_line add -d HOSTPERFDATA
error:

nagios安装配置pnp4nagios-0.6_第2张图片

define command {
      command_name    process-service-perfdata
      command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
}

define command {
      command_name    process-host-perfdata
      command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}

三张图:
nagios安装配置pnp4nagios-0.6_第3张图片
113141660.jpg
nagios安装配置pnp4nagios-0.6_第4张图片