From 4755abc5915ce3e77304823928ee31f9c5ac498d Mon Sep 17 00:00:00 2001
From: Ton Voon <tonvoon@users.sourceforge.net>
Date: Wed, 29 Jan 2003 05:10:49 +0000
Subject: Added dummy login test (650970 - Ton Voon)

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@263 f882894a-f735-0410-b71e-b25c423dba1c

diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index d2a84fe..7e2f6f9 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -36,6 +36,7 @@ print_usage() {
   echo "Usage:"
   echo "  $PROGNAME --tns <Oracle Sid or Hostname/IP address>"
   echo "  $PROGNAME --db <ORACLE_SID>"
+  echo "  $PROGNAME --login <ORACLE_SID>"
   echo "  $PROGNAME --oranames <Hostname>"
   echo "  $PROGNAME --help"
   echo "  $PROGNAME --version"
@@ -53,6 +54,8 @@ print_help() {
   echo "--db=SID"
   echo "   Check local database (search /bin/ps for PMON process and check"
 	echo "   filesystem for sgadefORACLE_SID.dbf"
+  echo "--login=SID"
+  echo "   Attempt a dummy login and alert if not ORA-01017: invalid username/password"
   echo "--oranames=Hostname"
   echo "   Check remote Oracle Names server"
   echo "--help"
@@ -81,6 +84,26 @@ case "$1" in
     ;;
 esac
 
+# Information options
+case "$cmd" in
+--help)
+		print_help
+    exit $STATE_OK
+    ;;
+-h)
+		print_help
+    exit $STATE_OK
+    ;;
+--version)
+		print_revision $PLUGIN $REVISION
+    exit $STATE_OK
+    ;;
+-V)
+		print_revision $PLUGIN $REVISION
+    exit $STATE_OK
+    ;;
+esac
+
 # Hunt down a reasonable ORACLE_HOME
 if [ -z "$ORACLE_HOME" ] ; then
 	# Adjust to taste
@@ -156,21 +179,17 @@ case "$cmd" in
 	exit $STATE_CRITICAL
     fi
     ;;
---help)
-		print_help
-    exit $STATE_OK
-    ;;
--h)
-		print_help
-    exit $STATE_OK
-    ;;
---version)
-		print_revision $PLUGIN $REVISION
-    exit $STATE_OK
-    ;;
--V)
-		print_revision $PLUGIN $REVISION
-    exit $STATE_OK
+--login)
+    loginchk=`sqlplus dummy/user@$2 < /dev/null`
+    loginchk2=` echo  $loginchk | grep -c ORA-01017`
+    if [ ${loginchk2} -eq 1 ] ; then 
+	echo "OK - dummy login connected"
+	exit $STATE_OK
+    else
+	loginchk3=` echo "$loginchk" | grep "ORA-" | head -1`
+	echo "CRITICAL - $loginchk3"
+	exit $STATE_CRITICAL
+    fi
     ;;
 *)
     print_usage
-- 
cgit v0.10-9-g596f

