nagios安装PNP图形化工具

首先安装必要软件:
安装扩展源:
访问https://fedoraproject.org/wiki/EPEL/zh-cn,选择相应的epel-release'包
安装:
wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm

yum -y install php-gd rrdtool-perl rrdtool

或是编译安装:(不建议,依赖关系太复杂)
1、从http://oss.oetiker.ch/rrdtool/pub/?M=D 下载最新的的RRDtool:
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.6.tar.gz
tar xzf rrdtool-1.4.6.tar.gz
cd rrdtool-1.4.6
./configure --prefix=/usr/local/rrdtool
make && make install

2、从http://sourceforge.net/projects/pnp4nagios/files/PNP-0.4/ 下载最新的pnp
wget http://nchc.dl.sourceforge.net/sourceforge/pnp4nagios/pnp-0.4.14.tar.gz
tar -xzf pnp-0.4.14.tar.gz
cd pnp-0.4.14
./configure --with-nagios-user=nagios --with-nagios-group-nagios --with-rrdtool=/usr/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata/

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

修改配置文件:
cd /usr/local/nagios/etc/pnp/
rename .cfg-sample .cfg *.cfg-sample
vi process_perfdata.cfg
#可不改
# Loglevel 0=silent 1=normal 2=debug
#
#LOG_LEVEL = 0
LOG_LEVEL = 2  #日志级别改成debug模式

修改templates.cfg
vi /usr/local/nagios/etc/objects/templates.cfg
#add pnp host service
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
}      

修改:
vi /usr/local/nagios/etc/nagios.cfg

#Default Mode:
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata

#Bulk Mode with NPCD:
process_performance_data=1
service_perfdata_file=/usr/local/nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
host_perfdata_file=/usr/local/nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file

修改:
vi /usr/local/nagios/etc/objects/commands.cfg
两种模式任选一种即可
#Default Mode:
# 'process-host-perfdata' command definition
define command{
        command_name    process-host-perfdata
        command_line    /usr/local/nagios/libexec/process_perfdata.pl
        }

# 'process-service-perfdata' command definition
define command{
        command_name    process-service-perfdata
        command_line    /usr/local/nagios/libexec/process_perfdata.pl
        }

#Bulk Mode with NPCD:
define command{
        command_name    process-service-perfdata-file
        command_line    /bin/mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/perfdata/service-perfdata.$TIMET$
 }

define command{
        command_name    process-host-perfdata-file
        command_line    /bin/mv /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/perfdata/host-perfdata.$TIMET$
 }

修改相应的主机文件例如:
vi /usr/local/nagios/etc/hosts/192.168.56.103.cfg
define host{
        use                     linux-server,hosts-pnp            ; Name of host template to use
                                                        ; This host definition will inherit all variables that are defined
                                                        ; in (or inherited by) the linux-server host template definition.
        host_name               192.168.56.103
        alias                   Debian 6.0 Server
        address                 192.168.56.103
        contact_groups          admins
}

define  service{
        use                     generic-service,services-pnp
        host_name               192.168.56.103
        check_command           check_http
        register                        1
}

启动npcd服务:
/usr/local/nagios/bin/npcd -d -f /usr/local/nagios/etc/pnp/npcd.cfg

显示PHP GD Support not found.
安装 yum -y install php-gd
重启apache服务:
/etc/init.d/httpd restart

启动顺序:
nagios->npcd

加入自启动:
vi /etc/rc.local
#add nagios pnp
/usr/local/nagios/bin/npcd -d -f /usr/local/nagios/etc/pnp/npcd.cfg

本文出自 “share” 博客,谢绝转载!

你可能感兴趣的:(centos,职场,nagios,休闲,RDDtool)