References

Nagios exchange: http://exchange.nagios.org/directory/Plugins/Databases/Oracle/check_oracle_health/details

Developer page: http://labs.consol.de/lang/en/nagios/check_oracle_health/

Prerequisites

Oracle software

The Oracle database server must be up and running.

CentOS packages

yum -y install cpan sharutils

Perl packages

Find out the absolute path of ORACLE_HOME and set the Oracle environment. This is required for the installation of DBD::Oracle.

With Oracle XE:

ORACLE_HOME
su - oracle
echo $ORACLE_HOME
--> /u01/app/oracle/product/11.2.0/xe
exit
# back to root
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

With Oracle 11gR2, there is no default location for the Oracle environment; you may have a look at the start script in /etc/init.d and worm your way through it.

The environment being set, you can install the required Perl modules. This task takes some time, and you have to press <enter> quite often; I recommend to keep you finger on the <enter> key for some seconds to  fill the key buffer before filling your time with something more intelligent the looking at the terminal window:

Perl upgrade
cpan
install YAML
install Net::SMPP
install DBI
install DBD::Oracle
upgrade
reload CPAN
exit


Download and install the check_oracle_health plugin

Download

Check for the latest version at http://labs.consol.de/lang/en/nagios/check_oracle_health/, scroll down to "Download".

Download
cd /tmp
wget https://labs.consol.de/assets/downloads/nagios/check_oracle_health-3.1.0.3.tar.gz

tar xzf check_oracle_health-3.1.0.3.tar.gz
cd /tmp/check_oracle_health-*
./configure
make
make install
cp /usr/local/nagios/libexec/check_oracle_health /usr/lib64/nagios/plugins/


Set up the Oracle user "nagios"

Oracle user "nagios"
# as root:
su - oracle
sqlplus / as sysdba
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;
exit # leave SQL*Plus
exit # back to root

Test locally

Please replace the path to ORACLE_HOME and the connect string as appropriate. In the following example, the connect string refers to the alias in $ORACLE_HOME/network/admin/tnsnames.ora.

Test
/usr/local/nagios/libexec/check_oracle_health --connect XE --user nagios --password oradbmon --environment ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe --mode tablespace-usage

If you see an error message like "Perhaps a required shared library or dll isn't installed where expected" you should prepend LD_LIBRARY_PATH = $ORACLE_HOME/lib:

Test with LD_LIBRARY_PATH
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/xe/lib /usr/local/nagios/libexec/check_oracle_health --connect XE --user nagios --password oradbmon --environment ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe --mode tablespace-usage


Amend nrpe.cfg

Please replace the path to ORACLE_HOME as appropriate.

Add the following lines to you configuriation file, possibly /usr/local/nagios/etc/nrpe.cfg


nrpe.cfg
vi /usr/local/nagios/etc/nrpe.cfg
...
command[check_tnsping]=/usr/local/nagios/libexec/check_oracle_health --connect localhost --environment ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe --user nagios --password oradbmon --mode tnsping
command[check_flra]=/usr/local/nagios/libexec/check_oracle_health --connect XE --environment ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe --user nagios --password oradbmon --mode flash-recovery-area-usage
command[check_sga]=/usr/local/nagios/libexec/check_oracle_health --connect XE --environment ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe --user nagios --password oradbmon --mode sga-shared-pool-free
command[check_tablespaces]=/usr/local/nagios/libexec/check_oracle_health --connect XE --user nagios --password oradbmon --environment ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe --mode tablespace-usage

You may have to prepend LD_LIBRARY_PATH as explained above.

Test on Nagios server

Replace the "yourserver.yourdomain.tld" with the IP address or IP name of your Oracle server:

/usr/local/nagios/libexec/check_nrpe -H yourserver.yourdomain.tld -c check_tablespaces

Common Errors

You may have forgotten to prepend LD_LIBRARY_PATH - as an alternative, you can add it the the default environment script for the user running the nagios checks (most probably "nagios"). 

Check that $ORACLE_HOME/network/admin/tnsnames.ora is world readable.

  • No labels