Icingaweb2监控oracle数据库的安装配置流程

Icinga2安装配置check_oracle_health流程

1.安装

由于check_oracle_health是使用perl语言编写的,因此在安装该插件之前,首先要安装oracle的客户端实例,分别是basic,sqlplus,sdk包括perl的oracle插件(DBI和DBD)。

第一步: 下载Oracle Instant Client

Oracle Instant Client的主页在http://www.oracle.com/technology/tech/oci/instantclient/index.html;同一软件按配置分成了不同的可下载包,让用户可以按照自己的需求,找到最合适的部分下载。要成功配置DBD::Oracle, 需要instantclient-basic-xxx,instantclient-sdk-xxx,instantclient-sqlplus-xxx这三个文件,可以下载zip包或者rpm包,zip包的话使用unzip命令在当前目录解压这三个zip文件,会自动生成instantclient_xxx目录,这里面包含了以上三个包里面的所有文件。

这时候这三个zip文件已经没用,可以删之,也可备份供以后重用。

第二步:安装DBI

 wget  http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.609.tar.gz    

tar  zxvf  DBI-1.609.tar.gz      

cd  DBI-1.609

perl  Makefile.PL 

make all

make install 

第三步:安装DBD

wget http://mirrors.neusoft.edu.cn/cpan/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.52.tar.gz
tar zxvf DBD-Oracle-1.52.tar.gz 
cd DBD-Oracle-1.52
perl Makefile.PL

此时会遇到错误:

解决方法是配置相应的环境变量:

export ORACLE_HOME=/usr/lib/oracle/11.2/client64

注:此路径为安装的instance所在目录

export PATH=$ORACLE_HOME/bin:$PATH;

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
再执行perl Makefile.PL就可以了
make 
make install

第四步:安装check_oracle_health

wget http://labs.consol.de/wp-content/uploads/2009/09/check_oracle_health-1.6.3.tar.gz

tar zxvf check_oracle_health-1.6.3.tar.gz

cd check_oracle_health-1.6.3

./configure --prefix=/usr/lib/nagios/plugins --with-nagios-user=nagios --with-nagios-group=nagios --with-mymodules-dir=/usr/lib/nagios/plugins/libexec --with-mymodules-dyn-dir=/usr/lib/nagios/plugins/libexec

make all

make install

安装完毕后,进入libexec目录下查看已经有这个插件了。

在此目录下打开终端,运行插件相应的命令,观察是否能够正常执行,返回相应的结果。

2.配置

Icinga2的配置文件与icinga1有很大不同,icinga1的配置文件均在object目录下,分别是hosts.cfg,commands.cfg和services.cfg。但是icinga2的配置文件分为两部分,一部分在/etc/icinga2/conf.d目录下的hosts.conf和services.conf文件,另一部分是位于/usr/share/icinga2/include目录下的command-plugins.conf文件。这三个文件与icinga1的文件的对应关系为

Icinga1                                                  icinga2

hosts.cfg             < ————— >     hosts.conf

services.cfg        < ————— >     services.conf

commands.cfg    < ————— >    command-plugins.conf

具体配置示例:

host.conf文件配置:

      添加主机:

           object Host "Host_Name" {

                  import "generic-host"

                  address = "the host’s IP"

}

command-plugins.conf文件配置:

           添加命令:

           object CheckCommand " Custom Command " {

                  import "plugin-check-command"

                  command = [ PluginDir + " /<file name stored in plugin directory> " ]

                  /*define all require arguments*/

                  arguments = {

                         "--connect"="$connection$"

                    "--username"="$user_name$"

                         "--password"="$pwd$"

                         "--mode"="$Mode$"

                         "--warning"="$W_ARG$"

                         "--critical"="$C_ARG$"

                  }

       vars.connection = "the host’s hostname or address you want to connect"

                  vars.user_name = "user name"

                  vars.pwd = "password"

}

services.conf文件配置:

      添加服务:

apply Service "Service Description" {

       import "generic-service"

       check_command = "Custom Command"

       vars.Mode = "select mode you want to Monitor "

       vars.W_ARG = beyond parameter1 cause Warning

       vars.C_ARG = beyond parameter2 cause Critical

  assign where host.name == " Host_Name "

}

把相应的主机,命令和服务都配好后,

重启icnga2:systemctl restart icinga2

打开浏览器,输入:http://localhost/icingaweb2/

登录icingaweb2监控页查看相关的监控信息。

至此,配置完成。

原文地址:https://www.cnblogs.com/herblog/p/5082184.html