Module: check_mk
Branch: master
Commit: 05a988500e5c1d319129b8e4861aa6cba69b01a6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=05a988500e5c1d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Apr 14 15:54:17 2015 +0200
Fix for ORACLE remote monitoring
---
.werks/1903 | 25 ++++++++++++++-----------
agents/plugins/mk_oracle | 18 +++++++++++-------
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/.werks/1903 b/.werks/1903
index 24bf084..1ac0a5f 100644
--- a/.werks/1903
+++ b/.werks/1903
@@ -21,28 +21,31 @@ host with mk_oracle is responsible for the piggyback data. If you put
the Check_
in downtime you'll put all other database checks from mk_oracle in a downtime as
well.
H2: Configuration
-You need an Oracle Client. If ORACLE_HOME is not set in the login shell of root, you
need
-to add the ORACLE_HOME variable to mk_oracle.mk.
+You need an Oracle Client. You could use the remote option from an existing Database
Server
+to monitor another Server. It is recommended to set
<tt>ORACLE_HOME_REMOTE</tt> in <tt>mk_oracle.cfg</tt>
+for the <tt>ORACLE_HOME</tt> which should be used for all remote
connections.
+
+An existing <tt>ORACLE_HOME</tt> could be used as well, but do not do that in
mixed configurations
+with local and remote monitoring of Oracle Databases.
Add the following lines to <tt>mk_oracle.cfg</tt>. The path is an example for
the RPM Instant
-Client from Oracle for 64bit.
-<tt>ORACLE_HOME=/usr/lib/oracle/11.2/client64</tt>
+Client from Oracle for 64bit on Linux.
+<tt>REMOTE_ORACLE_HOME=/usr/lib/oracle/11.2/client64</tt>
-<tt>REMOTE_INSTANCE_1_omd110=check_mk:check_mk:::::XE:11.2</tt>
-<tt>REMOTE_INSTANCE_2_omd110=check_mk:check_mk:::::XE2:11.2</tt>
+<tt>REMOTE_INSTANCE_1=check_mk:check_mk::dbhost:1521:piggybackhost:XE:11.2</tt>
+<tt>REMOTE_INSTANCE_2=check_mk:check_mk::dbhost:1521:piggybackhost:XE2:11.2</tt>
Definition of a REMOTE_INSTANCE:
-<tt>REMOTE_INSTANCE_<Number>_<piggyback Hostname>=<Configuration
String></tt>
+<tt>REMOTE_INSTANCE_<Number>=<Configuration String></tt>
The definition of the database connection is as follows.
-<tt><username>:<password>:<sysdba>:<port>:<Database
hostname>:<reserved for future
use>:<ORACLE_SID>:<ORACLE-Release></tt>
+<tt><username>:<password>:<sysdba>:<Database
hostname>:<Listener Port><piggyback
Hostname>:<ORACLE_SID>:<ORACLE-Release></tt>
Notes regarding <tt>REMOTE_INSTANCE_x</tt>
You need to make sure, that the name of the variable including
the hostname is unique for every database in <tt>mk_oracle.cfg</tt>.
-Only 3 '_' are allowed in front of the piggyback hostname.
-Otherwise the plugin won't work correctly. The Oracle Release must
-be 9.2, 10.1, 10.2, 11.1, 11.2 or 12.1. No other values are allowed.
+The Oracle Release must be 9.2, 10.1, 10.2, 11.1, 11.2 or 12.1.
+No other values are allowed.
Don't forget to use the testmode before starting the inventory on
the monitoring host.
diff --git a/agents/plugins/mk_oracle b/agents/plugins/mk_oracle
index f0599bf..f07030c 100755
--- a/agents/plugins/mk_oracle
+++ b/agents/plugins/mk_oracle
@@ -694,7 +694,7 @@ function set_oraenv () {
if [[ "$SID" =~ ^REMOTE_INSTANCE_.* ]] ; then
# we get the ORACLE_HOME from mk_oracle.cfg for REMOTE execution
- ORACLE_HOME=${ORACLE_HOME:-${REMOTE_ORACLE_HOME}}
+ ORACLE_HOME=${ORACLE_HOME:-${ORACLE_HOME_REMOTE}}
else
# we need to keep an existing ORACLE_SID in remote mode
@@ -835,7 +835,7 @@ function sqlplus() {
TNSALIAS=$(echo $REMOTE_VARNAME | cut -d"_" -f3-)
# we need to add the piggyback sections!
- remote_hostname=$(echo $SID | cut -d"_" -f4-)
+ remote_hostname=$(echo ${ORACFGLINE} | cut -d":" -f$[6])
# build the piggyback information in loc_stdin
# <<<<hostname>>>> SQL-Statements
<<<<>>>>
@@ -1114,12 +1114,13 @@ function do_instance() {
# '----------------------------------------------------------------------'
# Are there any remote configurations?
-for element in $(compgen -A variable | grep -E "^REMOTE_INSTANCE_.*_.*") ; do
+for element in $(compgen -A variable | grep -E "^REMOTE_INSTANCE_.*") ; do
REMOTE_DBS=$REMOTE_DBS" "$element
- element_suffix=$(echo $element | cut -d"_" -f4-)
- REMOTE_HOSTLIST=${element_suffix}" "${REMOTE_HOSTLIST}
+ remote_hostname=$(echo $element | cut -d":" -f6)
+
+ REMOTE_HOSTLIST=${remote_hostname}" "${REMOTE_HOSTLIST}
done
if [ "$REMOTE_HOSTLIST" ] ; then
@@ -1127,9 +1128,9 @@ if [ "$REMOTE_HOSTLIST" ] ; then
REMOTE_HOSTLIST=$(echo $REMOTE_HOSTLIST | tr ' ' '\n' | sort | uniq)
# create empty piggyback SECTIONS
- for remote_hostname in $REMOTE_HOSTLIST ; do
+ for element in $REMOTE_HOSTLIST ; do
- rhostname=$(echo $remote_hostname | cut -d"_" -f3- )
+ remote_hostname=$(echo $element | cut -d":" -f6)
echo "<<<<"$remote_hostname">>>>"
for section in $SYNC_SECTIONS $ASYNC_SECTIONS $SYNC_ASM_SECTIONS
$ASYNC_ASM_SECTIONS
@@ -1206,6 +1207,9 @@ for REMOTE_DB in $REMOTE_DBS ; do
# the ORACLE_SID is needed for the oracle_instance check for ASM and normal instance
ORACLE_SID=$(echo $REMOTE_DB_LINE | cut -d":" -f7)
+ # This is the piggyback hostname
+ remote_hostname=$(echo $element | cut -d":" -f6)
+
get_oraversion $REMOTE_DB
do_instance $REMOTE_DB
done