Skip to content


nagios 3.X 安装 pnp 增加绘图功能

参考:
http://www.pnp4nagios.org/pnp/start
http://www.pnp4nagios.org/pnp/install

Required Software
Perl >= 5.x without additional modules
RRDtool >= 1.x, better 1.2 but not compulsory
Attention: installing RRDtool without a packet manager might lead to missing dejavu fonts. If you see graphs without text then this may be the cause.
PHP >= 4.3.8 for Webfrontend
PHP-extension zlib and GD.
Nagios 2.x oder higher

rrdtool安装参考
http://blog.c1gstudio.com/archives/459
nagios安装参考
http://blog.c1gstudio.com/archives/545

安装pnp

wget http://nchc.dl.sourceforge.net/sourceforge/pnp4nagios/pnp-0.4.14.tar.gz
tar -xvzf pnp-0.4.14.tar.gz
cd pnp-0.4.14
./configure


checking for rrdtool… no
checking rrdtool path … no
configure: error: is a directory! PNP needs the Path to the rrdtool binary!

export PKG_CONFIG_PATH=/usr/local/rrdtool/lib/pkgconfig
export PKG_CONFIG=/usr/local/rrdtool/bin/pkg-config
export PATH=/usr/local/rrdtool/bin:$PATH

*** Configuration summary for pnp 0.4.14 05-02-2009 ***

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.3.7
RRDs Perl Modules: *** NOT FOUND ***
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/

Review the options above for accuracy. If they look okay,
type ‘make all’ to compile.

WARNING: The RRDs Perl Modules are not found on your System
Using RRDs will speedup things in larger Installtions.


make all
make install
make install-config
make install-init

process_perfdata.pl 安装在 /usr/local/nagios/share/
配置示例文件安装在/usr/local/nagios/libexecs
config.php安装于/usr/local/nagios/etc/pnp

修改配置文件

cp /usr/local/nagios/etc/pnp/process_perf
data.cfg-sample /usr/local/nagios/etc/pnp/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

在界面上加上小太阳
参考:http://www.pnp4nagios.org/pnp/webfe

修改etc/objects/templates.cfg增加新命令

define host {
name host-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
process_perf_data 1
}

define service {
name srv-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}

修改etc/objects/localhost.cfg增加相应命令

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

修改etc/nagios.cfg
找到如下几项,去掉注释

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

修改commands.cfg

# ‘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
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}

# ‘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
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl
}

修改pnp的web服务器配置文件nginx.conf,请注意安全问题,我这里未做安全验证。

location /pnp/ {
root /usr/local/nagios/share/;
location ~ .*\.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}

}

如果开启了open_basedir还需修改php.ini

open_basedir = “/opt/htdoc:/opt/php/lib/php:/tmp/session:/tmp/upload:/usr/local/nagios/share/pnp:/usr/local/nagios/etc/pnp:/usr/local/nagios/share/perfdata:/usr/local/rrdtool/bin/rrdtool”

重新加载配置文件

service nagios reload
/bin/kill -HUP `cat /dev/shm/nginx.pid`

http://localhost/nagios
点击小太阳就可以看到图表了

Posted in Nagios, 技术.

Tagged with , .


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. johnny says

    你好:
    我在看你的关于rrdtool的安装文档,写的非常的棒,在按照文档进行操作到fontconfig安装的时候出现错误./configure的时候一切正常,在meke的是偶出现如下错误不知道解决烦请帮忙看一下。期待您的Email。谢谢!
    gcc -shared .libs/fcatomic.o .libs/fcblanks.o .libs/fccache.o .libs/fccfg.o .libs/fccharset.o .libs/fcdbg.o .libs/fcdefault.o .libs/fcdir.o .libs/fcfreetype.o .libs/fcfs.o .libs/fcinit.o .libs/fclang.o .libs/fclist.o .libs/fcmatch.o .libs/fcmatrix.o .libs/fcname.o .libs/fcpat.o .libs/fcserialize.o .libs/fcstr.o .libs/fcxml.o .libs/ftglue.o -Wl,–rpath -Wl,/usr/local/rrdtool/lib -Wl,–rpath -Wl,/usr/local/rrdtool/lib -L/usr/local/rrdtool/lib /usr/local/rrdtool/lib/libfreetype.so -lz /usr/lib/libexpat.so -Wl,–rpath -Wl,/usr/local/rrdtool/lib -Wl,–rpath -Wl,/usr/local/rrdtool/lib -Wl,-soname -Wl,libfontconfig.so.1 -o .libs/libfontconfig.so.1.2.0
    /usr/lib/libexpat.so: could not read symbols: File in wrong format
    collect2: ld returned 1 exit status
    make[3]: *** [libfontconfig.la] Error 1
    make[3]: Leaving directory `/tmp/rrdbuild/fontconfig-2.4.2/src’
    make[2]: *** [all] Error 2
    make[2]: Leaving directory `/tmp/rrdbuild/fontconfig-2.4.2/src’
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/tmp/rrdbuild/fontconfig-2.4.2′
    make: *** [all] Error 2

  2. C1G says

    我放狗搜了下,可能你使用的是64位的系统,在configure时加上–with-expat-lib=/usr/lib64 试试。



Some HTML is OK

or, reply to this post via trackback.