AlexNogard: IT HowTo

Linux & Opensource : Monitoring : Centreon, Nagios, Owncloud ..

By

Monitoring Oracle Database with Check_oracle_health & Nagios / Centreon

oracle logoCheck_oracle_health is a great Oracle Database monitoring Tools. This plugin help you retrieve a variety of data such as the time to connect to a database, the number of connected users, the invalid objects sum, free space in a tablespace and many other counters …

We will use it with Centreon to exploit check_oracle_health data monitoring  as graphs. A dedicated Nagios part is also in this article.

Before implementing check_oracle_health plugin, several elements must be installed as Oracle instantclient and some perl libraries.

To install the various packages provided by Oracle, please visit the Instant Client Downloads page, download the following packages:

  • oracle-instantclient12.1-basic-12.1.0.1.0-1.x86_64.rpm
  • oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.x86_64.rpm
  • oracle-instantclient12.1-devel-12.1.0.1.0-1.x86_64.rpm
  • oracle-instantclient12.1-jdbc-12.1.0.1.0-1.x86_64.rpm

To install:

# rpm -Uvh oracle-instantclient12.1-basic-12.1.0.1.0-1.x86_64.rpm
# rpm -Uvh oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.x86_64.rpm
# rpm -Uvh oracle-instantclient12.1-devel-12.1.0.1.0-1.x86_64.rpm
# rpm -Uvh oracle-instantclient12.1-jdbc-12.1.0.1.0-1.x86_64.rpm

We also install some necessary packages:

# yum install libdbi-drivers libdbi perl-DBI

Then the Perl library: DBD-Oracle, necessary for the proper functioning of the plugin check_oracle_health :

# wget http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.66.tar.gz
# tar xvzf DBD-Oracle-1.66.tar.gz
# cd DBD-Oracle-1.66
# export ORACLE_HOME=/usr/lib/oracle/12.1/client/lib
# export LD_LIBRARY_PATH=$ORACLE_HOME
# perl Makefile.PL
# make
# make install

We download and install check_oracle_health:

# wget http://labs.consol.de/download/shinken-nagios-plugins/check_oracle_health-1.7.8.1.tar.gz
# tar xzvf check_oracle_health-1.7.8.1.tar.gz
# cd check_oracle_health-1.7.8.1
# ./configure –prefix=/usr/local/nagios/libexec –with-nagios-user=nagios –with-nagios-group=nagios
# make
# make install

Then, as recommended by the plugin developer, we create a dedicated user for monitoring, connect to your Oracle database and enter the following lines:

CREATE USER nagios IDENTIFIED BY oradbmon;
GRANT CREATE SESSION TO nagios;
GRANT SELECT any dictionary TO nagios;
GRANT SELECT ON V_$SYSSTAT TO nagios;
GRANT SELECT ON V_$INSTANCE TO nagios;
GRANT SELECT ON V_$LOG TO nagios;
GRANT SELECT ON SYS.DBA_DATA_FILES TO nagios;
GRANT SELECT ON SYS.DBA_FREE_SPACE TO nagios;

Then, we test the proper operation of our plugin:

# /usr/local/nagios/libexec/check_oracle_health –connect=XXX.XXX.XXX.XXX –username=nagios –password=nagios –tablespace=SUPERVISION  –mode tablespace-usage

CRITICAL - tbs SYSTEM usage is 99.33%

Nagios

To monitor your Oracle database with check_oracle_health from Nagios, we create the following command in checkcommand.cfg:

define command{
command_name                    check_oracle_health
command_line                    /usr/local/nagios/libexec/check_oracle_health –connect=X.X.X.X –username=nagios –password=nagios –tablespace=SUPERVISION  –mode $ARG1$ –warning=$ARG2$ –critical=$ARG3$
}

Then add in services.cfg the following parameters:

Connected users :

define service{
host_name                               Oracle-Server
service_description             Check_connected-users
use                             Oracle-server
check_command                   check_oracle_health!connected-users!80!100
}

Connection Time :

define service{
host_name                               Oracle-Server
service_description             Check_connected-users
use                             Oracle-server
check_command                   check_oracle_health!connection-time!50!100
}

Invalid Objects :

define service{
host_name                               Oracle-Server
service_description             Check_connected-users
use                             Oracle-server
check_command                   check_oracle_health!invalid-objects
}

TableSpace Usage :

define service{
host_name                               Oracle-Server
service_description             Check_connected-users
use                             Oracle-server
check_command                   check_oracle_health!tablespace-usage!80!90
}

Centreon

To add check_oracle_health plugin into Centreon: We connect to Centreon, then create the following command:
check_oracle_health command

It only remains to attach services to your hosts by changing the three arguments :).

Here is the result of “Connection time” :

Oracle-Server-Check_connection-time

Oracle-Server-Check_connection-time

To know the whole list of ways that you can use with check_oracle_health, follow the link ;).

From Now, you are monitoring your Oracle database with Centreon / Nagios and Check_oracle_health plugin.

If you have any comments, questions, do not hesitate;). Also do not hesitate to share this article.

One Response to Monitoring Oracle Database with Check_oracle_health & Nagios / Centreon

  1. Jane says:

    hi!!!
    what version of Instant Client packages must I installed?
    I have Nagios 3.0 on my CentOS release 5.8 (Final) where I have a Oracle db 11.0
    .
    thanks in advance..

Leave a Reply

Your email address will not be published. Required fields are marked *