一.安装rrdtool
RRDTOOL将nagios采集的数据绘制成图表。
#wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.3.tar.gz
#tar zxvf rrdtool-1.4.3.tar.gz -C ../software
#cd ../softwar/rrdtool-1.4.3
#./configure
--prefix=/usr/local/rrdtool/
--with-perl-options=/usr/bin/perl 指定perl路径
#make
#make install
二.安装pnp
#wget http://downloads.sourceforge.net/project/pnp4nagios/PNP/pnp-0.4.14/pnp-0.4.14.tar.gz?use_mirror=nchc
#tar zxvf pnp-0.4.14.tar.gz -C ../software/
#cd ../software/pnp-0.4.14
#./configure /
--with-nagios-user=nagios/
--with-nagios-group=nagios/
--with-rrdtool=/usr/local/rrdtool/bin/rrdtool/ 指定rrdtool路径
--with-perfdata-dir=/usr/local/nagios/share/perfdata/ 指定perfdata存放路径
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
Location of rrdtool binary: /usr/local/rrdtool/bin/rrdtool Version 1.4.3
RRDs Perl Modules: FOUND (Version 1.4003)
RRD Files stored in: /usr/local/nagios/share/perfdata/
process_perfdata.pl Logfile: /usr/local/nagios/var/perfdata.log
Perfdata files (NPCD) stored in: /usr/local/nagios/var/spool/perfdata/
#make all
#make install
#make install-config
#make install-init
三.配置nagios
#vi /usr/local/nagios/etc/nagios (在880行左右)
process_performance_data=1 //开启收集perfdata(默认是关闭的)
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
#vi /usr/local/nagios/etc/objects/commands.cfg
增加对process-host-perfdata,process-service-perfdata命令的定义
define command{
command_name process-service-perfdata //定义命令名称
command_line /usr/local/nagios/libexec/process_perfdata.pl //指定命名
}
define command{
command_name process-service-perfdata
command_line /usr/local/nagios/libexec/process_perfdata.pl
}
# vi /usr/local/nagios/etc/objects/templates.cfg
添加太阳图标,配置前端页面
define service{
name generic-service
process_perf_data 1 //开启收集perfdata
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$ //定义URL
}
define service{
name local-service
use generic-service
action_url /nagios/pnp/index.php?host=$HOSTNAME$
process_perf_data 1
}
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 检测配置
#service nagios restart
四.验证
http://localhost/nagios/pnp/