nagios的安装不再赘述,直接在nagios服务端进行安装pnp4nagios软件
安装展示图形页面pnpnagios(rrdtool工具用来存储数据并画图,pnpnagios用来展示图形数据)
参考:http://docs.pnp4nagios.org/pnp-0.6/install
http://docs.pnp4nagios.org/pnp-0.6
tar xf pnp4nagios-0.6.25.tar.gz
cd pnp4nagios-0.6.25
yum install rrdtool rrdtool-perl -y
./configure
编译报错:
checking for Perl Module Time::HiRes... no
configure: error: Perl Module Time::HiRes not available
解决办法:
yum -y install perl-Time-HiRes
再次编译
./configure
make all
make install
make install-webconf
make install-config
make install-init
make fullinstall
安装后出现如下输出:
*** Configuration summary for pnp4nagios-0.6.25 03-01-2015 ***
General Options:
------------------------- -------------------
Nagios user/group: nagios nagios
Install directory: /usr/local/pnp4nagios
HTML Dir: /usr/local/pnp4nagios/share
Config Dir: /usr/local/pnp4nagios/etc
Location of rrdtool binary: /usr/bin/rrdtool Version 1.3.8
RRDs Perl Modules: FOUND (Version 1.3008)
RRD Files stored in: /usr/local/pnp4nagios/var/perfdata
process_perfdata.pl Logfile: /usr/local/pnp4nagios/var/perfdata.log
Perfdata files (NPCD) stored in: /usr/local/pnp4nagios/var/spool
Web Interface Options:
------------------------- -------------------
HTML URL: http://localhost/pnp4nagios
Apache Config File: /etc/httpd/conf.d/pnp4nagios.conf
Review the options above for accuracy. If they look okay,
type 'make all' to compile.
由于nagios采用的是4.1.1,pnp4nagios采用的是0.6.25
在官方文档有好几种配置pnp4nagios的模式,但是采用sync的模式会一直收集不到数据,而报错,于是改用了Bulk Mode with NPCD,成功出图,这里分析配置过程:
参考:http://www.aboutmonitoring.com/installing-nagios-core-4-pnp4nagios-check_mk-nagvis-centos-7-redhat-7/
1、编辑nagios.cfg文件,修改
process_performance_data=0将这个值改为1
##### Values: 1 = process performance data, 0 = do not process performance data
enable_environment_macros=1
Your environment passed all requirements. Remove or rename the /usr/local/pnp4nagios/share/install.php file now.
解决办法:
mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.ignore
define service {
name srv-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
定义完成之后,最后只需在定义的hosts、services配置文件中加入下操作:
define host{
use linux-server,host-pnp ; Name of host templates to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name localhost
alias localhost
address 127.0.0.1
}
define service{
use local-service,srv-pnp ; Name of service template to use
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
于是整个配置工作完成,访问浏览器出图如下