【基本介绍】
Pnp 是一个基于 php 和 perl,用 rrdtool将 nagios 采集的数据绘制图表的工具。
【安装流程】
1.安装php - 省略
2.安装perl - 省略
3.安装pnp
tar xf pnp4nagios-0.6.6.tar.gz
cd pnp4nagios-0.6.6
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata
make all
make install
make install-config
make install-init
安装完成,PNP默认文件放置情况如下:
General Options:
----------------------------- -------------------
Nagios user/group: nagios nagios
Install directory: /usr/local/nagios
HTML Dir: /usr/local/nagios/share/pnp
Config Dir: /usr/local/nagios/etc/pnp
Path to rrdtool: /usr/local/bin/rrdtool (Version 1.4.5)
RRDs Perl Modules: *** NOT FOUND ***
RRD Files stored in: /usr/local/nagios/share/perfdata
process_perfdata.pl Logfile: /usr/local/nagios/var/perfdata.log
-------------------------------------------------------------------------
【pnp配置】
1.创建配置文件
cd /usr/local/nagios/etc/pnp/
cp process_perfdata.cfg-sample process_perfdata.cfg
cp npcd.cfg-sample npcd.cfg
cp rra.cfg-sample rra.cfg
chown -R nagios:nagios *
② 修改process_perfdata.cfg文件
vi /usr/local/nagios/etc/pnp/process_perfdata.cfg
LOG_FILE =/usr/local/nagios/var/perfdata.log
# Loglevel 0=silent 1=normal 2=debug
LOG_LEVEL = 2
这里将日志级别改为2,即为debug模式。
2.PNP配置文件pnp.cfg的hosts和services
define host {
name hosts-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
process_perf_data 1
}
define service {
name services-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
3.修改nagios.cfg配置
# PROCESS PERFORMANCE DATA OPTION
# This determines whether or not Nagios will process performance
# data returned from service and host checks. If this option is
# enabled, host performance data will be processed using the
# host_perfdata_command (defined below) and service performance
# data will be processed using the service_perfdata_command (also
# defined below). Read the HTML docs for more information on
# performance data.
# Values: 1 = process performance data, 0 = do not process performance data
process_performance_data=1
# HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS
# These commands are run after every host and service check is
# performed. These commands are executed only if the
# enable_performance_data option (above) is set to 1. The command
# argument is the short name of a command definition that you
# define in your host configuration file. Read the HTML docs for
# more information on performance data.
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
4.修改commands.cfg,把文件最后定义的注释掉,添加如下信息,用process_perfdata.pl读取host、service信息
define command{
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl
}
define command{
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
4.在需要图像的服务或者host配置文件中添加对应的服务
define host{
use linux-server,hosts-pnp
host_name mysql
alias ixdba-mysql
address 192.168.12.237
}
define service{
use local-service,services-pnp
host_name mysql
service_description SSH
check_command check_ssh
}
【pnp出图测试】
wget http://verify.pnp4nagios.org/verify_pnp_config
chmod +x verify_pnp_config
perl verify_pnp_config --mode sync --config=/usr/local/nagios/etc/nagios.cfg --pnpcfg=/usr/local/pnp4nagios/etc
【pnp模式介绍】
省略
【自定义脚本nagios出图】
省略
【参考引用】
http://www.cnblogs.com/dyllove98/archive/2013/06/28/3161559.html
http://blog.csdn.net/zhsh87/article/details/8662837
http://exchange.nagios.org/directory/Plugins/Software/check_memcached-2Epl/details
http://www.it165.net/admin/html/201309/1803.html
http://blog.chinaunix.net/uid-25266990-id-3437195.html