Centos5.6下安装NagiosPNP-创新互联

去官方下载最新的版本nagios-4.0.8 http://www.nagios.org/download/core

成都创新互联公司专注于企业成都全网营销推广、网站重做改版、上城网站定制设计、自适应品牌网站建设、H5高端网站建设商城网站建设、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为上城等各大城市提供网站开发制作服务。

[root@nagios nagios]# tar zxvf nagios-4.0.8.tar.gz

[root@nagios nagios-4.0.8]# make all

[root@nagios nagios-4.0.8]#  make install

[root@nagios nagios-4.0.8]# make install-init

[root@nagios nagios-4.0.8]#  make install-commandmode

[root@nagios nagios-4.0.8]#  make install-config

[root@nagios nagios-4.0.8]# make install-webconf

[root@nagios nagios-4.0.8]# make install-exfoliation

[root@nagios nagios-4.0.8]#  make install-classicui

2:安装插件  nagios-plugins-2.0.3.tar.gz  http://www.nagios.org/download/plugins

./configure&&make&&make install

ln -s /usr/local/nagios /etc/nagios

个性化的插件都拷贝到/etc/nagios/libexec 下

3:安装iostat_plugins 需要如下rpm包包

[root@nagios iostat_plugins]# ls -h
perl-Class-Accessor-0.31-1.el5.rf.noarch.rpm  perl-Params-Validate-0.89-1.el5.rf.i386.rpm
perl-Config-Tiny-2.12-1.el5.rf.noarch.rpm     perl-Regexp-Common-2.120-1.2.el5.rf.noarch.rpm
perl-Math-Calc-Units-1.06-1.el5.rf.noarch.rpm

如下插件都可以网上找 主要是check_traffic.sh

cp check_memory.pl check_iostat check_file_des check_inode check_netstat check_traffic.sh /usr/local/nagios/libexec
chmod 755 /usr/local/nagios/libexec/check_memory.pl
chmod 755 /usr/local/nagios/libexec/check_iostat
dos2unix /usr/local/nagios/libexec/check_memory.pl
dos2unix /usr/local/nagios/libexec/check_iostat

使用check_traffic.sh之前需要安装snmp包snmpwalk

 rpm -ivh net-snmp-utils-5.3.2.2-9.el5_5.1.i386.rpm

 mkdir -p /var/tmp/nagios && chown -R nagios.nagios /var/tmp/nagios

 例子:如何获取交换机的端口信息

/usr/local/nagios/libexec/check_traffic.sh -V 2c -C 3550b -H 172.16.40.9 -L

4:优化部分

[root@nagios etc]# cd /etc/nagios/etc

[root@nagios etc]# htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
New password:
Re-type new password:
Adding password for user admin

编辑cgi.cfg文件,替换nagiosadmin 为admin

/etc/init.d/nagios start

/etc/init.d/httpd start

5:绘图PNP

http://docs.pnp4nagios.org/pnp-0.6/dwnld

下载:pnp4nagios-0.6.24.tar.gz            文档部分    http://docs.pnp4nagios.org/pnp-0.6/start

 PNP是一个Nagios插件 ***能数据进行分析,并将它们存储自动RRD-databases

RRDtool是开源行业标准,可以提供高性能数据记录时间序列数据和图形绘制系统

下载链接:http://oss.oetiker.ch/rrdtool/pub/?M=D

此处使用rrdtool-1.2.12.tar.gz

[root@nagios rrdtool-1.2.12]# ./configure

[root@nagios rrdtool-1.2.12]# make all &&make install

[root@nagios pnp4nagios-0.6.24]# ls /usr/local/rrdtool-1.2.12/ 安装好的目录

[root@nagios ~]#   cd pnp4nagios-0.6.24

[root@nagios pnp4nagios-0.6.24]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool-1.2.12/bin/rrdtool

[root@nagios pnp4nagios-0.6.24]# make all

[root@nagios pnp4nagios-0.6.24]#  make install

[root@nagios pnp4nagios-0.6.24]# make install-webconf

[root@nagios pnp4nagios-0.6.24]# make install-config

*** PNP4Nagios sample config files installed ***

Please run 'make install-init' if you want to use
BULK Mode with NPCD

默认是运行Synchronous Mode 模式,比较浪费资源它是每一个事件将触发process-service-perfdata的执行

 所以此处使用Bulk mode 批量模式比同步模式更为复杂但能显著降低nagios服务器上的负载,因为数据收集器process_perfdata.pl不调用每个服务/主机检查。

在批量模式Nagios将数据写入一个临时文件中。这个文件是由process_perfdata进行处理。在特定的间隔。Nagios将定期照顾启动和运行它

  •  首先在nagios.cfg中 启用收据收集开关

process_performance_data=1

#
# service performance data
#
service_perfdata_file=/usr/local/pnp4nagios/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 performance data starting with Nagios 3.0
#
host_perfdata_file=/usr/local/pnp4nagios/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

  • 编辑command.cfg

    define command{
          command_name   process-service-perfdata-file
          command_line   /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/service-perfdata
    }

    define command{
          command_name   process-host-perfdata-file
          command_line   /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/host-perfdata
    }

6: 调试

http://192.168.10.100/pnp4nagios/   提示404错误

                     chown nagios.nagios /usr/local/nagios/etc/htpasswd.users

PNP4Nagios Versionpnp4nagios-0.6.24
Prefix/usr/local/pnp4nagios
Configure Arguments./configure '--with-nagios-user=nagios' '--with-nagios-group=nagios' '--with-rrdtool=/usr/local/rrdtool-1.2.12/bin/rrdtool'
RRD Storage/usr/local/pnp4nagios/var/perfdata is readable.
RRDtool Binary/usr/local/rrdtool-1.2.12/bin/rrdtool is executable by PHP
PHP GD extensionPHP GD extension not available
PHP function proc_open()Pass
PHP zlib extensionPass
PHP session extensionPass
PHP JSON extensionPass
PHP magic_quotes_gpcOff
PHP socket extensionPass
Apache Rewrite ModulePass

 在安装光盘上查询依次安装即可,缺啥补啥

[root@nagios CentOS]# ls *php* | grep gd
php53-gd-5.3.3-1.el5.i386.rpm
php-gd-5.1.6-27.el5_5.3.i386.rpm

 然后重启WEB 刷新通过。

Your environment passed all requirements. Remove or rename the /usr/local/pnp4nagios/share/install.php file now.

                                        cd /usr/local/pnp4nagios/share/

[root@nagios share]#  mv install.php install.php.bak

  • 编辑模板新增vim templates.cfg

define host {
  name      host-pnp
  action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
  register  0
}

define service {
  name      srv-pnp
  action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
  register  0
}

在LINUX 被监控端安装nagios-plugins-2.0.3  nrpe-2.15.tar.gz

运行方式:

 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站栏目:Centos5.6下安装NagiosPNP-创新互联
网页链接:http://scyanting.com/article/cccjsj.html