[nagiosplug] Add option to perform real login in check_oracle

Nagios Plugin Development nagios-plugins at users.sourceforge.net
Mon Mar 25 23:30:23 CET 2013


    Module: nagiosplug
    Branch: master
    Commit: b57dc1b3a0b7e43739c60f3f317416b0f3aa793c
    Author: Brian De Wolf <git at bldewolf.com>
 Committer: Holger Weiss <holger at zedat.fu-berlin.de>
      Date: Tue Jan 15 17:03:03 2013 -0800
       URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=b57dc1b

Add option to perform real login in check_oracle

The Oracle plugin has no option for testing for a successful login.  The
closest option to this is --login, which uses a fixed set of credentials and
expects to receive the logon failure error code.

This patch adds an option called --connect.  This option takes a full SID and
returns success if it doesn't detect any error codes.  With this, we can check
that a database is allowing logins from valid credentials (and avoid filling up
DB logs with failed authentications).

---

 plugins-scripts/check_oracle.sh |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index 664795e..2a8ab21 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -18,6 +18,7 @@ print_usage() {
   echo "  $PROGNAME --tns <Oracle Sid or Hostname/IP address>"
   echo "  $PROGNAME --db <ORACLE_SID>"
   echo "  $PROGNAME --login <ORACLE_SID>"
+  echo "  $PROGNAME --connect <ORACLE_SID>"
   echo "  $PROGNAME --cache <ORACLE_SID> <USER> <PASS> <CRITICAL> <WARNING>"
   echo "  $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING>"
   echo "  $PROGNAME --oranames <Hostname>"
@@ -39,6 +40,8 @@ print_help() {
   echo "   filesystem for sgadefORACLE_SID.dbf"
   echo "--login SID"
   echo "   Attempt a dummy login and alert if not ORA-01017: invalid username/password"
+  echo "--connect SID"
+  echo "   Attempt a login and alert if an ORA- error is returned"
   echo "--cache"
   echo "   Check local database for library and buffer cache hit ratios"
   echo "       --->  Requires Oracle user/password and SID specified."
@@ -187,6 +190,18 @@ case "$cmd" in
 	exit $STATE_CRITICAL
     fi
     ;;
+--connect)
+    connectchk=`sqlplus $2 < /dev/null`
+    connectchk2=` echo  $connectchk | grep -c ORA-`
+    if [ ${connectchk2} -eq 0 ] ; then
+	echo "OK - login successful"
+	exit $STATE_OK
+    else
+	connectchk3=` echo "$connectchk" | grep "ORA-" | head -1`
+	echo "CRITICAL - $connectchk3"
+	exit $STATE_CRITICAL
+    fi
+    ;;
 --cache)
     if [ ${5} -gt ${6} ] ; then
 	echo "UNKNOWN - Warning level is less then Crit"





More information about the Commits mailing list