安装rrdtools(绘图工具)可能需要的库
一.编译安装rrdtool
yum install -y pango pango-devel freetype freetype-devel libpng libpng-devel gettext gettext-devel libjpeg libjpeg-devel gd gd-devel libxml2 libxml2-devel libiconv libiconv-devel qpixman qpixman-devel glib glib-devel cairo cairo-devel libart*
下载:http://oss.oetiker.ch/rrdtool/pub/?M=D
安装rrdtools
./configure
make
make install
二.yum简单安装rrdtool方法:
[root@localhost]# cd /etc/yum.repos.d/
[root@localhost]# vim 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@localhost]#yum install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bisonautoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devellibpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel pam-devel
[root@localhost]# yum install -y rrdtool perl-rrdtool rrdtool-devel
安装PNP
http://docs.pnp4nagios.org/pnp-0.4/dwnld
下载最新版
# tar xvf pnp- laster.tar.gz
# cd pnp-laster
#./configure --with-nagios-user=nagios --with-nagios-group=nagios--with-rrdtool=/opt/rrdtool-1.4.7/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata
# make all && make install&& make install-config && make install-init
配置PNP
# 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 /usr/local/nagios/etc/pnp/
修改process_perfdata.cfg文件
# vim /usr/local/nagios/etc/pnp/process_perfdata.cfg修改如下:
LOG_FILE = /usr/local/nagios/var/perfdata.log
LOG_LEVEL = 2 (debug)
修改Nagios配置文件
1.增加小太阳图标
修改templates.cfg,增加一个定义PNP的host和service。修改后的内容如下:
define host{
name hosts-pnp
register 0
action_url /pnp/index.php?host=$HOSTNAME$
process_perf_data 1
}
define service{
name services-pnp
register 0
action_url /pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
修改nagios.cfg,找到以下几项,去掉注释。修改后的信息如下:
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
修改commands.cfg
define command{
command_name process-host-perfdata
command_line /usr/local/nagios/libexec/process_perfdata.pl -dHOSTPERFDATA
#这样才显示ping数据
}
define command{
command_name process-service-perfdata
command_line /usr/local/nagios/libexec/process_perfdata.pl
}
修改hosts.cfg和services.cfg
hosts.cfg
define host{
use linux-server,hosts-pnp
host_name www-syj
alias www-syj
address 192.168.1.60
}
define host{
use linux-server,hosts-pnp
host_name 111-syj
alias 111-syj
address 192.168.1.111
}
define hostgroup{
hostgroup_name sa-servers
alias sa servers
members www-syj,111-syj
}
servers.cfg
###########################www-syj###########################
define service{
use local-service,services-pnp
host_name www-syj
service_description check-swap
check_command check_nrpe!check_swap
}
define service{
use local-service,services-pnp
host_name www-syj
service_description check-load
check_command check_nrpe!check_load
}
define service{
use local-service,services-pnp
host_name www-syj
service_description check-users
check_command check_nrpe!check_users
}
测试PNP功能
# service nagios restart
如果配置正确,此时就会生成相应的主机的PNP文件。
点击小太阳均可进入pnp查看图形
出现问题:
网上说 templates.cfg中
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
这样导致很多图片获取不到,用网页工具查看到有很多图片的路径(根据nginx的配置不同而不同)不正确
Chmod 777/usr/local/nagios/share/pnp/images
将action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$改为:
action_url /pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
service nagios reload
图片就显示出来了:
升级到0.6.*
1. planning the new setup
2. perform test installation and acquaintoneself with the new system
3. create backup of the old installation
4. install PNP 0.6.x at /usr/local/pnp4nagios
5. make install-config
6. make install-webconf
7. reload Apache
8. test Apache-config
I. call of /pnp4nagios has to report anempty perfdata directory
9. create /usr/local/pnp4nagios/etc/npcd.cfg from npcd.cfg-sample
I. check paths and adapt changes from 0.4.xif necessary
10. adjustall paths in nagios.cfg to the new PNP installation
11. adjustall paths in the command definitions
12. stopnpcd using /etc/init.d/npcd stop
13. make install-init installsthe new init script for npcd
14. /etc/init.d/nagios stop
15. copy /usr/local/nagios/share/perfdata to /usr/local/pnp4nagios/var/perfdata.Attention: check the permissions
16. /etc/init.d/npcd start
17. /etc/init.d/nagios start