Module: check_mk
Branch: master
Commit: b43a09daabfe23e516ff0014dd4f703e568aa21b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b43a09daabfe23…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jan 28 12:43:10 2011 +0100
mk_oracle: port to HP-UX
---
ChangeLog | 2 +-
agents/{ => plugins}/mk_logwatch | 0
agents/plugins/mk_oracle | 23 +++++++++++++++--------
agents/{plugins => }/sqlplus.sh | 4 +++-
checkman/oracle_logswitches | 2 +-
checkman/oracle_sessions | 2 +-
checkman/oracle_tablespaces | 2 +-
7 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f83e970..6b8edaa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,7 +21,7 @@
* drbd: Fixed var typo which prevented inventory of drbd general check
(Thanks to Andreas Behler)
* mk_oracle: new agent plugin for monitoring ORACLE (currently only
- on Linux, but easily portable to other Unices)
+ on Linux and HP-UX, but easily portable to other Unices)
* oracle_sessions: new check for monitoring the current number of active
database sessions.
* oracle_logswitches: new check for monitoring the number of logswitches
diff --git a/agents/mk_logwatch b/agents/plugins/mk_logwatch
similarity index 100%
rename from agents/mk_logwatch
rename to agents/plugins/mk_logwatch
diff --git a/agents/plugins/mk_oracle b/agents/plugins/mk_oracle
index a0faf17..4f311ea 100644
--- a/agents/plugins/mk_oracle
+++ b/agents/plugins/mk_oracle
@@ -26,23 +26,30 @@
# Check_MK agent plugin for monitoring ORACLE databases
# Get list of all running databases
-SIDS=$(UNIX95=true ps ax -o args | sed -n '/^ora_pmon_\([^ ]*\)/s//\1/p')
+if [ $(uname -s) = Linux ]
+then
+ PS="ps ax -o args"
+else
+ PS="ps -ef -o args"
+fi
+
+SIDS=$(UNIX95=true $PS | sed -n '/^ora_pmon_\([^ ]*\)/s//\1/p')
if [ -z "$SIDS" ] ; then exit 0 ; fi
# Make an sqlplus query, clean up the result and add an artificial
# column with the SID at the front of each line. If the query fails,
# no output at all is made.
-function sqlplus ()
-{
+function sqlplus
+{
OUTPUT=$({ echo 'set pages 0' ; echo 'set lines 8000' ; echo 'set
feedback off'; cat ; } | $MK_CONFDIR/sqlplus.sh $1) || return 1
- echo "${OUTPUT}" | sed -e 's/[[:space:]]\+/ /g' -e
'/^[[:space:]]*$/d' -e "s/^/$1 /"
+ echo "${OUTPUT}" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e
'/^[[:space:]]*$/d' -e "s/^/$1 /"
}
# Sessions
echo '<<<oracle_sessions>>>'
for SID in $SIDS
do
- echo "select count(*) from v"'$'"session where status =
'ACTIVE';" | sqlplus "$SID"
+ echo "select count(*) from v"'$'"session where status =
'ACTIVE';" | sqlplus "$SID"
done
echo '<<<oracle_logswitches>>>'
@@ -53,13 +60,13 @@ select count(*) from v\$loghist where first_time > sysdate - 1/24;
EOF
done
-
+
# Tablespaces
echo '<<<oracle_tablespaces>>>'
for SID in $SIDS
do
- sqlplus "$SID" <<EOF
-select f.file_name, f.tablespace_name, f.status, f.AUTOEXTENSIBLE, f.blocks, f.maxblocks,
f.USER_BLOCKS, f.INCREMENT_BY, f.ONLINE_STATUS, t.BLOCK_SIZE, t.status from
dba_data_files f, dba_tablespaces t where f.tablespace_name = t.tablespace_name
+ sqlplus "$SID" <<EOF | sed 's/READ ONLY/READONLY/g'
+select f.file_name, f.tablespace_name, f.status, f.AUTOEXTENSIBLE, f.blocks, f.maxblocks,
f.USER_BLOCKS, f.INCREMENT_BY, f.ONLINE_STATUS, t.BLOCK_SIZE, t.status from
dba_data_files f, dba_tablespaces t where f.tablespace_name = t.tablespace_name
UNION
select f.file_name, f.tablespace_name, f.status, f.AUTOEXTENSIBLE, f.blocks, f.maxblocks,
f.USER_BLOCKS, f.INCREMENT_BY, 'TEMP', t.BLOCK_SIZE, t.status from
dba_temp_files f, dba_tablespaces t where f.tablespace_name = t.tablespace_name;
EOF
diff --git a/agents/plugins/sqlplus.sh b/agents/sqlplus.sh
similarity index 95%
rename from agents/plugins/sqlplus.sh
rename to agents/sqlplus.sh
index 929eab6..f1fb379 100755
--- a/agents/plugins/sqlplus.sh
+++ b/agents/sqlplus.sh
@@ -1,5 +1,7 @@
#!/bin/sh
+# EXAMPLE
+
# This script is called by the Check_MK ORACLE plugin in order to
# execute an SQL query.
@@ -15,7 +17,7 @@ if [ -z "$ORACLE_SID" ] ; then
exit 1
fi
-su - nagios -c "
+su nagios -c "
ORACLE_SID=$ORACLE_SID
ORAENV_ASK=NO
. /usr/local/bin/oraenv
diff --git a/checkman/oracle_logswitches b/checkman/oracle_logswitches
index 77623db..0133e06 100644
--- a/checkman/oracle_logswitches
+++ b/checkman/oracle_logswitches
@@ -1,5 +1,5 @@
title: Check log switch activity of ORACLE database
-agents: linux
+agents: linux, hpux
author: Mathias Kettner <mk(a)mathias-kettner.de>
license: GPL
distribution: check_mk
diff --git a/checkman/oracle_sessions b/checkman/oracle_sessions
index 5f2571d..ff2caa9 100644
--- a/checkman/oracle_sessions
+++ b/checkman/oracle_sessions
@@ -1,5 +1,5 @@
title: Check number of active sessions in ORACLE database
-agents: linux
+agents: linux, hpux
author: Mathias Kettner <mk(a)mathias-kettner.de>
license: GPL
distribution: check_mk
diff --git a/checkman/oracle_tablespaces b/checkman/oracle_tablespaces
index f94aa09..1dc7ee6 100644
--- a/checkman/oracle_tablespaces
+++ b/checkman/oracle_tablespaces
@@ -1,5 +1,5 @@
title: Check various aspects of ORACLE tablespaces
-agents: linux
+agents: linux, hpux
author: Mathias Kettner <mk(a)mathias-kettner.de>
license: GPL
distribution: check_mk