This how-to describes how to setup your OP5 Monitor server with Oracle Instant Client to be able to use the plugin check_oracle directly towards the Oracle Database. This means we eliminate the use of 3rd party agents on the server, and it's the same syntax for Linux/UNIX and Windows platforms. In this how-to we will use version 184.108.40.206.0 of Oracle Instant Client. The 11-series client works for checks against Oracle 11 and Oracle 10 databases. The word '#' means that you will need to type a command in the command line interface.
- Please note that Instant Client version 11.2 is incompatible with Oracle Database 12c. For Oracle Database 12c, please download and install Instant Client version 19.6 which is the latest version as at the time of updating this article.
This article is outdated.On supported versions, follow these instructions instead for environment variables. This article is kept for historical reasons only.
Oracle Instant Client installed on your OP5 Monitor server.
- A user with sufficient access to the databases you want to monitor is needed. The user needs the following permissions:
create user <USER> identified by <PASSWORD>;
grant create session to <USER>;
grant select any dictionary to <USER>;
grant select on V_$SYSSTAT to <USER>;
grant select on V_$INSTANCE to <USER>;
grant select on V_$LOG to <USER>;
grant select on SYS.DBA_DATA_FILES to <USER>;
grant select on SYS.DBA_FREE_SPACE to <USER>;
Oracle Instant Client
- Download the Oracle Instant Client basic and sqlplus packages from Oracle, https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html and transfer them to your OP5 Monitor server.
- Log on to your OP5 Monitor server using SSH. Install the Oracle Instant Client packages using yum.
# yum install oracle-instantclient11.2-sqlplus*.rpm oracle-instantclient11.2-basic*.rpm
A set of environment variables are needed. Note that this process will differ between EL6 and EL7. Regardless of variant, you may create /etc/profile.d/check_oracle.sh with the following contents to set up interactive shells correctly:
Further configuration necessary for Naemon to correctly inherit the environment variables:
/etc/sysconfig/naemon already exists, simply add your variables to the end of the file. Every line is required to start with the word "export", just like the check_oracle.sh example above.
/etc/sysconfig/naemon already exists but may not function correctly, this is being worked on.
If you are having issues with the below instructions, you may also want to read How to add environment variables to naemon check_commands.
You can still define variables in /etc/sysconfig/naemon manually, and your variables must not be defined with the "export" command, they should be defined in this syntax:
Test and verify environment variables are visible to Naemon (important)
Open up the OP5 Monitor GUI, click "Manage" > "Configure" > "Commands". Enter this command and test it:
printenvYou should see your defined variables as Naemon runs the command.
- Now log out the current SSH session, and then log on again.
- Verify that the environment variables were properly read at log-on by printing their content into the terminal (this is only relevant for interactive shells):
# echo $ORACLE_HOME
# echo $TNS_ADMIN
# echo $LD_LIBRARY_PATH
- Install SQL*Plus and configuration files.
# ln -s $ORACLE_HOME/bin/sqlplus /usr/bin/sqlplus
# touch $TNS_ADMIN/sqlnet.ora
# touch $TNS_ADMIN/tnsnames.ora
Edit /etc/tnsnames.ora according to your Oracle Environment.
If you need more information on how to set up this file, please consult your Oracle administrator.
- You should now be able to connect to you database with the following command:
# sqlplus <user>/<password>@op5
Not required for check_oracle.pl
To write own plugins and use DBI to connect to Oracle you need to have all the above steps working.
Install gcc and then proceed with installing DBD::Oracle from CPAN.
# yum install gcc
# perl -MCPAN -e 'install DBD::Oracle'
DBI support with DBD::Oracle module is now installed.
Getting tnsping to work
The following steps are not supported by op5 or Oracle, but are known to work. If you are having problem though, you could also use the dummy login test instead. (check_oracle -l <SID>)
To get tnsping to work you have to copy tnsping and tnsus.msb from an existing Linux Oracle installation, preferably from an RedHat 4/5 Installation. put the file in $ORACLE_HOME.
Place tnsping in /usr/lib/oracle/11.2/client64/tnsping
Place tnsus.msb in /usr/lib/oracle/11.2/client64/network/mesg/tnsus.msb
Make sure you have read permission to tnsus.msb for user "monitor"
Create symlinks to get tnsping to work:
# ln -s $ORACLE_HOME/tnsping /usr/bin/tnsping
# cd /usr/lib/oracle/11.2/client64
# ln -s lib/libclntsh.so.11.1 libclntsh.so.10.1
# ln -s lib/libnnz11.so libnnz10.so
Verify that your tnsping is working.
# tnsping op5Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP)(HOST = oracle.op5.com)(PORT = 1521)))(CONNECT_DATA = (SID = op5)))OK (40 msec)
The last thing you need to do is to restart op5 Monitor. This is done with the following command:
# service naemon restart