This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: STABLE2 - rgmanager: Update SAPInstance / SAPDatabase tocurrent versions


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=12d137bce7f1e0e8d0e5b896dcb5b78084559d82
Commit:        12d137bce7f1e0e8d0e5b896dcb5b78084559d82
Parent:        1597c5738f1675e32f97205dd866178bade61d22
Author:        Mark Hlawatschek <hlawatschek@atix.de>
AuthorDate:    Wed Dec 10 09:39:56 2008 -0500
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Tue Jan 13 06:01:07 2009 +0100

rgmanager: Update SAPInstance / SAPDatabase to current versions

---
 rgmanager/src/resources/SAPDatabase |  444 +++++++++++++++++++++++++++++------
 rgmanager/src/resources/SAPInstance |  327 ++++++++++++++++++++------
 2 files changed, 625 insertions(+), 146 deletions(-)

diff --git a/rgmanager/src/resources/SAPDatabase b/rgmanager/src/resources/SAPDatabase
index a614dc9..70adbcc 100644
--- a/rgmanager/src/resources/SAPDatabase
+++ b/rgmanager/src/resources/SAPDatabase
@@ -6,9 +6,9 @@
 #               as a High-Availability OCF compliant resource.
 #
 # Author:       Alexander Krauth, October 2006
-# Support:      liunx@sap.com
+# Support:      linux@sap.com
 # License:      GNU General Public License (GPL)
-# Copyright:    (c) 2006 Alexander Krauth
+# Copyright:    (c) 2006, 2007 Alexander Krauth
 #
 # An example usage: 
 #      See usage() function below for more details...
@@ -19,8 +19,16 @@
 #       OCF_RESKEY_DBTYPE
 #       OCF_RESKEY_NETSERVICENAME   (optional, non standard name of Oracle Listener)
 #       OCF_RESKEY_DBJ2EE_ONLY      (optional, default is false)
+#       OCF_RESKEY_JAVA_HOME        (optional, only needed if DBJ2EE_ONLY is true and JAVA_HOME enviroment variable is not set)
+#       OCF_RESKEY_STRICT_MONITORING (optional, activate application level monitoring - with Oracle a failover will occur in case of an archiver stuck)
+#       OCF_RESKEY_AUTOMATIC_RECOVER (optional, automatic startup recovery, default is false)
 #       OCF_RESKEY_DIR_BOOTSTRAP    (optional, if non standard J2EE server directory)
 #       OCF_RESKEY_DIR_SECSTORE     (optional, if non standard J2EE secure store directory)
+#       OCF_RESKEY_DB_JARS          (optional, if maintained in bootstrap.properties, mandatory for WebAS Java 7.10)
+#	OCF_RESKEY_PRE_START_USEREXIT	(optional, lists a script which can be executed before the resource is started)
+#	OCF_RESKEY_POST_START_USEREXIT	(optional, lists a script which can be executed after the resource is started)
+#	OCF_RESKEY_PRE_STOP_USEREXIT	(optional, lists a script which can be executed before the resource is stopped)
+#	OCF_RESKEY_POST_STOP_USEREXIT	(optional, lists a script which can be executed after the resource is stopped)
 #
 # ToDo:
 # Remove all the database dependend stuff from the agent and use
@@ -29,15 +37,13 @@
 #######################################################################
 # Initialization:
 
-if [ -f /usr/lib/heartbeat/ocf-shellfuncs ]; then
-	. /usr/lib/heartbeat/ocf-shellfuncs
+if [ -f ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs ]; then
+        . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
 elif [ -f /usr/share/cluster/ocf-shellfuncs ]; then
-	. /usr/share/cluster/ocf-shellfuncs
-elif [ -f `dirname $0`/ocf-shellfuncs ]; then
-	. `dirname $0`/ocf-shellfuncs
+        . /usr/share/cluster/ocf-shellfuncs
 else
-	echo Could not find ocf-shellfuncs!
-	exit 1
+        echo Could not find ocf-shellfuncs!
+        exit 1
 fi
 
 #######################################################################
@@ -67,9 +73,9 @@ usage() {
 meta_data() {
 	cat <<END
 <?xml version="1.0"?>
-<!DOCTYPE resource-agent SYSTEM "ra-api-1-modified.dtd">
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
 <resource-agent name="SAPDatabase">
-<version>1.2</version>
+<version>1.92</version>
 
 <longdesc lang="en">
 Resource script for SAP databases. It manages a SAP database of any type as an HA resource.
@@ -77,47 +83,87 @@ Resource script for SAP databases. It manages a SAP database of any type as an H
 <shortdesc lang="en">SAP database resource agent</shortdesc>
 
 <parameters>
- <parameter name="SID" unique="1" required="1" primary="1">
+ <parameter name="SID" unique="1" required="1">
   <longdesc lang="en">The unique SAP system identifier. e.g. P01</longdesc>
   <shortdesc lang="en">SAP system ID</shortdesc>
   <content type="string" default="" />
  </parameter>
- <parameter name="DIR_EXECUTABLE" unique="1" required="0">
+ <parameter name="DIR_EXECUTABLE" unique="0" required="0">
   <longdesc lang="en">The full qualified path where to find sapstartsrv and sapcontrol.</longdesc>
   <shortdesc lang="en">path of sapstartsrv and sapcontrol</shortdesc>
   <content type="string" default="" />
  </parameter>
- <parameter name="DBTYPE" unique="1" required="1">
+ <parameter name="DBTYPE" unique="0" required="1">
   <longdesc lang="en">The name of the database vendor you use. Set either: ORA,DB6,ADA</longdesc>
   <shortdesc lang="en">database vendor</shortdesc>
   <content type="string" default="" />
  </parameter>
- <parameter name="NETSERVICENAME" unique="1" required="0">
+ <parameter name="NETSERVICENAME" unique="0" required="0">
   <longdesc lang="en">The Oracle TNS listener name.</longdesc>
   <shortdesc lang="en">listener name</shortdesc>
   <content type="string" default="" />
  </parameter>
- <parameter name="DBJ2EE_ONLY" unique="1" required="0">
+ <parameter name="DBJ2EE_ONLY" unique="0" required="0">
   <longdesc lang="en">If you do not have a ABAP stack installed in the SAP database, set this to TRUE</longdesc>
   <shortdesc lang="en">only JAVA stack installed</shortdesc>
   <content type="boolean" default="false"/>
  </parameter>
- <parameter name="DIR_BOOTSTRAP" unique="1" required="0">
+ <parameter name="JAVA_HOME" unique="0" required="0">
+  <longdesc lang="en">This is only needed if the DBJ2EE_ONLY parameter is set to true. Enter the path to the Java SDK which is used by the SAP WebAS Java</longdesc>
+  <shortdesc lang="en">Path to Java SDK</shortdesc>
+  <content type="string" default=""/>
+ </parameter>
+ <parameter name="STRICT_MONITORING" unique="0" required="0">
+  <longdesc lang="en">This controls how the resource agent monitors the database. If set to true, it will use SAP tools to test the connect to the database. Do not use with Oracle, because it will result in unwanted failovers in case of an archiver stuck</longdesc>
+  <shortdesc lang="en">Activates application level monitoring</shortdesc>
+  <content type="boolean" default="false"/>
+ </parameter>
+ <parameter name="AUTOMATIC_RECOVER" unique="0" required="0">
+  <longdesc lang="en">The SAPDatabase resource agent tries to recover a failed start attempt automaticaly one time. This is done by running a forced abort of the RDBMS and/or executing recovery commands.</longdesc>
+  <shortdesc lang="en">Enable or disable automatic startup recovery</shortdesc>
+  <content type="boolean" default="false"/>
+ </parameter>
+ <parameter name="DIR_BOOTSTRAP" unique="0" required="0">
   <longdesc lang="en">The full qualified path where to find the J2EE instance bootstrap directory. e.g. /usr/sap/P01/J00/j2ee/cluster/bootstrap</longdesc>
   <shortdesc lang="en">path to j2ee bootstrap directory</shortdesc>
   <content type="string" default="" />
  </parameter>
- <parameter name="DIR_SECSTORE" unique="1" required="0">
+ <parameter name="DIR_SECSTORE" unique="0" required="0">
   <longdesc lang="en">The full qualified path where to find the J2EE security store directory. e.g. /usr/sap/P01/SYS/global/security/lib/tools</longdesc>
   <shortdesc lang="en">path to j2ee secure store directory</shortdesc>
   <content type="string" default="" />
  </parameter>
+ <parameter name="DB_JARS" unique="0" required="0">
+  <longdesc lang="en">The full qualified filename of the jdbc driver for the database connection test. It will be automaticaly read from the bootstrap.properties file in Java engine 6.40 and 7.00. For Java engine 7.10 the parameter is mandatory.</longdesc>
+  <shortdesc lang="en">file name of the jdbc driver</shortdesc>
+  <content type="string" default="" />
+ </parameter>
+ <parameter name="PRE_START_USEREXIT" unique="0" required="0">
+  <longdesc lang="en">The full qualified path where to find a script or program which should be executed before this resource gets started.</longdesc>
+  <shortdesc lang="en">path to a pre-start script</shortdesc>
+  <content type="string" default="" />
+ </parameter>
+ <parameter name="POST_START_USEREXIT" unique="0" required="0">
+  <longdesc lang="en">The full qualified path where to find a script or program which should be executed after this resource got started.</longdesc>
+  <shortdesc lang="en">path to a post-start script</shortdesc>
+  <content type="string" default="" />
+ </parameter>
+ <parameter name="PRE_STOP_USEREXIT" unique="0" required="0">
+  <longdesc lang="en">The full qualified path where to find a script or program which should be executed before this resource gets stopped.</longdesc>
+  <shortdesc lang="en">path to a pre-start script</shortdesc>
+  <content type="string" default="" />
+ </parameter>
+ <parameter name="POST_STOP_USEREXIT" unique="0" required="0">
+  <longdesc lang="en">The full qualified path where to find a script or program which should be executed after this resource got stopped.</longdesc>
+  <shortdesc lang="en">path to a post-start script</shortdesc>
+  <content type="string" default="" />
+ </parameter>
 </parameters>
 
 <actions>
 <action name="start" timeout="1800" />
 <action name="stop" timeout="1800" />
-<action name="status" timeout="60" />
+<action name="status" depth="0" timeout="60" interval="120" start-delay="180" />
 <action name="monitor" depth="0" timeout="60" interval="120" start-delay="180" />
 <action name="validate-all" timeout="5" />
 <action name="meta-data" timeout="5" />
@@ -230,11 +276,11 @@ x_server_stop() {
 # x_server_status: is the x_server running?
 #
 x_server_status() {
-  sdbuser=`ls -ld /sapdb/$SID | awk '{print $3}'`
+  sdbuser=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
   # Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be used here
   # as the output might be to long.
   cnt=`ps efo args --user $sdbuser | grep -c vserver`
-  if [ $cnt -eq 1 ]
+  if [ $cnt -ge 1 ]
   then
     rc=$OCF_SUCCESS
   else
@@ -290,6 +336,11 @@ return $retcode
 # maxdb_stop: Stop the MaxDB database without any condition
 #
 maxdb_stop() {
+
+# x_Server must be running to stop database
+x_server_status
+if [ $? -ne $OCF_SUCCESS ]; then x_server_start; fi
+
 if [ $DBJ2EE_ONLY -eq 1 ]; then
    userkey=c_J2EE
 else
@@ -350,6 +401,113 @@ return $retcode
 }
 
 #
+# oracle_recover: try to clean up oracle after a crash
+#
+oracle_recover() {
+echo '#!/bin/sh
+LOG=$HOME/recover.log
+date > $LOG
+echo "Logfile written by heartbeat SAPDatabase resource agent" >> $LOG
+
+if [ -x "${ORACLE_HOME}/bin/sqlplus" ]
+then
+    SRVMGRDBA_EXE="${ORACLE_HOME}/bin/sqlplus"
+else
+   echo "Can not find executable sqlplus" >> $LOG
+   exit 1
+fi
+
+$SRVMGRDBA_EXE /NOLOG >> $LOG << !
+connect / as sysdba
+shutdown abort
+startup mount
+WHENEVER SQLERROR EXIT SQL.SQLCODE
+WHENEVER OSERROR EXIT FAILURE
+alter database recover automatic database;
+alter database open;
+exit
+!
+rc=$?
+cat $LOG
+exit $rc' > $TEMPFILE
+
+  chmod 700 $TEMPFILE
+  chown $sidadm $TEMPFILE
+
+  su - $sidadm -c $TEMPFILE
+  retcode=$?
+  rm -f $TEMPFILE
+
+  return $retcode
+}
+
+#
+# maxdb_recover: try to clean up MaxDB after a crash
+#
+maxdb_recover() {
+  # x_Server must be running to stop database
+  x_server_status
+  if [ $? -ne $OCF_SUCCESS ]; then x_server_start; fi
+
+  if [ $DBJ2EE_ONLY -eq 1 ]; then
+     userkey=c_J2EE
+  else
+     userkey=c
+  fi
+
+echo "#!/bin/sh
+LOG=\$HOME/recover.log
+date > \$LOG
+echo \"Logfile written by heartbeat SAPDatabase resource agent\" >> \$LOG
+echo \"Cleanup database with xuserkey >$userkey<\" >> \$LOG
+echo \"db_stop\" >> \$LOG 2>&1
+dbmcli -U ${userkey} db_stop >> \$LOG 2>&1
+echo \"db_clear\" >> \$LOG 2>&1
+dbmcli -U ${userkey} db_clear >> \$LOG 2>&1
+echo \"db_online\" >> \$LOG 2>&1
+dbmcli -U ${userkey} db_online >> \$LOG 2>&1
+rc=\$?
+cat \$LOG
+exit \$rc" > $TEMPFILE
+
+  chmod 700 $TEMPFILE
+  chown $sidadm $TEMPFILE
+
+  su - $sidadm -c $TEMPFILE
+  retcode=$?
+  rm -f $TEMPFILE
+
+  return $retcode
+}
+
+#
+# db6udb_recover: try to recover DB/2 after a crash
+#
+db6udb_recover() {
+  db2sid="db2`echo $SID | tr [:upper:] [:lower:]`"
+
+echo '#!/bin/sh
+LOG=$HOME/recover.log
+date > $LOG
+echo "Logfile written by heartbeat SAPDatabase resource agent" >> $LOG
+$INSTHOME/sqllib/bin/db2_kill >> $LOG  2>&1
+$INSTHOME/sqllib/adm/db2start >> $LOG  2>&1
+$INSTHOME/sqllib/bin/db2 activate database $DB2DBDFT >> $LOG  2>&1
+rc=$?
+cat $LOG
+exit $rc' > $TEMPFILE
+
+  chmod 700 $TEMPFILE
+  chown $db2sid $TEMPFILE
+
+  su - $db2sid -c $TEMPFILE
+  retcode=$?
+  rm -f $TEMPFILE
+
+  return $retcode
+}
+
+#
 # methods: What methods/operations do we support?
 #
 sapdatabase_methods() {
@@ -367,9 +525,38 @@ sapdatabase_methods() {
 
 
 #
+# sapuserexit : Many SAP customers need some additional processes/tools to run their SAP systems.
+#               This specialties do not allow a totally generic SAP cluster resource agent.
+#               Someone should write a resource agent for each additional process you need, if it
+#               is required to monitor that process within the cluster manager. To enable
+#               you to extent this resource agent without developing a new one, this user exit
+#               was introduced.
+#
+sapuserexit() {
+  NAME="$1"
+  VALUE="$2"
+
+  if [ -n "$VALUE" ]
+  then
+    if [ -x "$VALUE" ]
+    then
+      ocf_log info "Calling userexit ${NAME} with customer script file ${VALUE}"
+      eval "$VALUE" >& /dev/null
+      ocf_log info "Exiting userexit ${NAME} with customer script file ${VALUE}, returncode: $?"
+    else
+      ocf_log warn "Attribute ${NAME} is set to ${VALUE}, but this file is not executable"
+    fi
+  fi
+  return 0
+}
+
+
+#
 # sapdatabase_start : Start the SAP database
 #
 sapdatabase_start() {
+  sapuserexit PRE_START_USEREXIT "$OCF_RESKEY_PRE_START_USEREXIT"
+
   case $DBTYPE in
     ADA) x_server_start
          ;;
@@ -378,14 +565,34 @@ sapdatabase_start() {
   esac
 
   output=`su - $sidadm -c $SAPSTARTDB`
-  if [ $? -eq 0 ]
+  rc=$?
+
+  if [ $DBJ2EE_ONLY -eq 1 ]
+  then
+    sapdatabase_monitor 1
+    rc=$?
+  fi
+
+  if [ $rc -ne 0 -a $OCF_RESKEY_AUTOMATIC_RECOVER -eq 1 ]
+  then
+    ocf_log warn "SAP database $SID start failed: $output"
+    ocf_log warn "Try to recover database $SID"
+
+    output=''
+    sapdatabase_recover
+    rc=$?
+  fi
+
+  if [ $rc -eq 0 ]
   then
     ocf_log info "SAP database $SID started: $output"
     rc=$OCF_SUCCESS
+    sapuserexit POST_START_USEREXIT "$OCF_RESKEY_POST_START_USEREXIT"
   else
     ocf_log err "SAP database $SID start failed: $output"
     rc=$OCF_ERR_GENERIC
   fi
+
   return $rc
 }
 
@@ -394,6 +601,8 @@ sapdatabase_start() {
 #
 sapdatabase_stop() {
 
+  sapuserexit PRE_STOP_USEREXIT "$OCF_RESKEY_PRE_STOP_USEREXIT"
+
   # use of the stopdb kernel script is not possible, because there are to may checks in that
   # script. We want to stop the database regardless of anything.
   #output=`su - $sidadm -c $SAPSTOPDB`
@@ -422,6 +631,9 @@ sapdatabase_stop() {
     ADA) x_server_stop
          ;;
   esac
+
+  sapuserexit POST_STOP_USEREXIT "$OCF_RESKEY_POST_STOP_USEREXIT"
+
   return $rc
 }
 
@@ -430,6 +642,7 @@ sapdatabase_stop() {
 # sapdatabase_monitor: Can the given database instance do anything useful?
 #
 sapdatabase_monitor() {
+  strict=$1
   rc=$OCF_SUCCESS
 
   case $DBTYPE in
@@ -441,43 +654,64 @@ sapdatabase_monitor() {
          ;;
   esac
 
-  if [ $DBJ2EE_ONLY -eq 0 ]
+  if [ $strict -eq 0 ]
   then
-    output=`echo "$SAPDBCONNECT -d -w /dev/null" | su $sidadm 2>&1`
-    if [ $? -le 4 ]
-    then
-      rc=$OCF_SUCCESS
-    else
-      rc=$OCF_NOT_RUNNING
-    fi
+    sapdatabase_status
+    rc=$?
   else
-    DB_JARS=""
-    if [ -f "$BOOTSTRAP"/bootstrap.properties ]; then
-      DB_JARS=`cat $BOOTSTRAP/bootstrap.properties | grep -i rdbms.driverLocation | sed -e 's/\\\:/:/g' | awk -F= '{print $2}'`
-    fi
-    IAIK_JCE="$SECSTORE"/iaik_jce.jar
-    IAIK_JCE_EXPORT="$SECSTORE"/iaik_jce_export.jar
-    EXCEPTION="$BOOTSTRAP"/exception.jar
-    LOGGING="$BOOTSTRAP"/logging.jar
-    OPENSQLSTA="$BOOTSTRAP"/opensqlsta.jar
-    TC_SEC_SECSTOREFS="$BOOTSTRAP"/tc_sec_secstorefs.jar
-    JDDI="$BOOTSTRAP"/../server0/bin/ext/jdbdictionary/jddi.jar
-    ANTLR="$BOOTSTRAP"/../server0/bin/ext/antlr/antlr.jar
-    FRAME="$BOOTSTRAP"/../server0/bin/system/frame.jar
-
-    # only start jdbcconnect when all jars available
-    if [ -f "$EXCEPTION" -a -f "$LOGGING" -a -f "$OPENSQLSTA" -a -f "$TC_SEC_SECSTOREFS" -a -f "$JDDI" -a -f "$ANTLR" -a -f "$FRAME" -a -f "$SAPDBCONNECT" ]
+    if [ $DBJ2EE_ONLY -eq 0 ]
     then
-      output=`eval java -cp ".:$FRAME:$ANTLR:$JDDI:$IAIK_JCE_EXPORT:$IAIK_JCE:$EXCEPTION:$LOGGING:$OPENSQLSTA:$TC_SEC_SECSTOREFS:$DB_JARS:$SAPDBCONNECT" com.sap.inst.jdbc.connect.JdbcCon -sec $SID:$SID`
-      if [ $? -le 0 ]
+      output=`echo "$SAPDBCONNECT -d -w /dev/null" | su $sidadm 2>&1`
+      if [ $? -le 4 ]
       then
         rc=$OCF_SUCCESS
       else
         rc=$OCF_NOT_RUNNING
       fi
     else
-      output="Cannot find all jar files needed for database monitoring."
-      rc=$OCF_ERR_GENERIC
+      MYCP=""
+      EXECMD=""
+
+      # WebAS Java 6.40+7.00
+      IAIK_JCE="$SECSTORE"/iaik_jce.jar
+      IAIK_JCE_EXPORT="$SECSTORE"/iaik_jce_export.jar
+      EXCEPTION="$BOOTSTRAP"/exception.jar
+      LOGGING="$BOOTSTRAP"/logging.jar
+      OPENSQLSTA="$BOOTSTRAP"/opensqlsta.jar
+      TC_SEC_SECSTOREFS="$BOOTSTRAP"/tc_sec_secstorefs.jar
+      JDDI="$BOOTSTRAP"/../server0/bin/ext/jdbdictionary/jddi.jar
+      ANTLR="$BOOTSTRAP"/../server0/bin/ext/antlr/antlr.jar
+      FRAME="$BOOTSTRAP"/../server0/bin/system/frame.jar
+  
+      # only start jdbcconnect when all jars available
+      if [ -f "$EXCEPTION" -a -f "$LOGGING" -a -f "$OPENSQLSTA" -a -f "$TC_SEC_SECSTOREFS" -a -f "$JDDI" -a -f "$ANTLR" -a -f "$FRAME" -a -f "$SAPDBCONNECT" ]
+      then
+        MYCP=".:$FRAME:$ANTLR:$JDDI:$IAIK_JCE_EXPORT:$IAIK_JCE:$EXCEPTION:$LOGGING:$OPENSQLSTA:$TC_SEC_SECSTOREFS:$DB_JARS:$SAPDBCONNECT" 
+        EXECMD="com.sap.inst.jdbc.connect.JdbcCon -sec $SID:$SID"
+      else
+      # WebAS Java 7.10
+        LAUNCHER=${BOOTSTRAP}/sap.com~tc~bl~offline_launcher~impl.jar
+
+        if [ -f "$DB_JARS" -a -f "$SAPDBCONNECT" -a -f "$LAUNCHER" ]
+        then
+          MYCP="$LAUNCHER"
+          EXECMD="com.sap.engine.offline.OfflineToolStart com.sap.inst.jdbc.connect.JdbcCon ${SAPDBCONNECT}:${SECSTORE}:${DB_JARS}:${BOOTSTRAP} -sec $SID:$SID"
+        fi
+      fi
+
+      if [ -n "$EXECMD" ]
+      then
+        output=`eval ${JAVA_HOME}/bin/java -cp $MYCP $EXECMD`
+        if [ $? -le 0 ]
+        then
+          rc=$OCF_SUCCESS
+        else
+          rc=$OCF_NOT_RUNNING
+        fi
+      else
+        output="Cannot find all jar files needed for database monitoring."
+        rc=$OCF_ERR_GENERIC
+      fi
     fi
   fi
 
@@ -495,7 +729,7 @@ sapdatabase_monitor() {
 sapdatabase_status() {
   case $DBTYPE in
     ADA) SEARCH="$SID/db/pgm/kernel"
-         SUSER=`ls -ld /sapdb/$SID | awk  '{print $3}'`
+         SUSER=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
          SNUM=2
          ;;
     ORA) SEARCH="ora_[a-z][a-z][a-z][a-z]_"
@@ -510,7 +744,7 @@ sapdatabase_status() {
 
   # Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be used here
   # as the output might be to long.
-  cnt=`ps efo args --user $SUSER | grep -c "$SEARCH"`
+  cnt=`ps efo args --user $SUSER 2> /dev/null | grep -c "$SEARCH"`
   if [ $cnt -ge $SNUM ]
   then
     rc=$OCF_SUCCESS
@@ -523,9 +757,37 @@ sapdatabase_status() {
 
 
 #
-# sapdatabase_vaildate: Check the symantic of the input parameters 
+# sapdatabase_recover:
+#
+sapdatabase_recover() {
+
+  case $DBTYPE in
+    ORA) recoutput=`oracle_recover`
+         ;;
+    ADA) recoutput=`maxdb_recover`
+         ;;
+    DB6) recoutput=`db6udb_recover`
+         ;;
+  esac
+
+  sapdatabase_monitor 1
+  retcode=$?
+
+  if [ $retcode -eq $OCF_SUCCESS ]
+  then
+    ocf_log info "Recover of SAP database $SID was successful: $recoutput"
+  else
+    ocf_log err "Recover of SAP database $SID failed: $recoutput"
+  fi
+
+  return $retcode
+}
+
+
+#
+# sapdatabase_validate: Check the symantic of the input parameters 
 #
-sapdatabase_vaildate() {
+sapdatabase_validate() {
   rc=$OCF_SUCCESS
   if [ `echo "$SID" | grep -c '^[A-Z][A-Z0-9][A-Z0-9]$'` -ne 1 ]
   then
@@ -555,7 +817,7 @@ then
 fi
 
 # Set a tempfile and make sure to clean it up again
-TEMPFILE="$(mktemp /tmp/SAPDatabase.tmp.XXXXXX)"
+TEMPFILE="/tmp/SAPDatabase.$$.tmp"
 trap trap_handler INT TERM
 
 # These operations don't require OCF instance parameters to be set
@@ -592,7 +854,7 @@ if [ -z "$OCF_RESKEY_DBTYPE" ]; then
   ocf_log err "Please set OCF_RESKEY_DBTYPE to the database vendor specific tag (ORA,ADA,DB6)!"
   exit $OCF_ERR_ARGS
 fi
-DBTYPE="$OCF_RESKEY_DBTYPE"
+DBTYPE=`echo "$OCF_RESKEY_DBTYPE" | tr "[a-z]" "[A-Z]"`
 
 # optional OCF parameters, we try to guess which directories are correct
 EXESTARTDB="startdb"
@@ -622,6 +884,17 @@ else
   NETSERVICENAME="$OCF_RESKEY_NETSERVICENAME"
 fi
 
+if [ -z "$OCF_RESKEY_STRICT_MONITORING" ]; then
+  OCF_RESKEY_STRICT_MONITORING=0
+else
+  case "$OCF_RESKEY_STRICT_MONITORING" in
+   1|true|TRUE|yes|YES) OCF_RESKEY_STRICT_MONITORING=1;;
+   0|false|FALSE|no|NO) OCF_RESKEY_STRICT_MONITORING=0;;
+   *)  ocf_log err "Parsing parameter STRICT_MONITORING: '$OCF_RESKEY_STRICT_MONITORING' is not a boolean value!"
+       exit $OCF_ERR_ARGS ;;
+  esac
+fi
+
 PATHLIST="
 $OCF_RESKEY_DIR_EXECUTABLE
 /usr/sap/$SID/*/exe
@@ -631,25 +904,19 @@ $OCF_RESKEY_DIR_EXECUTABLE
 DIR_EXECUTABLE=""
 for EXEPATH in $PATHLIST
 do
-  SAPSTARTDB=`which $EXEPATH/$EXESTARTDB 2> /dev/null`
-  if [ $? -eq 0 ]
+  if [ -x $EXEPATH/$EXESTARTDB -a -x $EXEPATH/$EXESTOPDB -a -x $EXEPATH/$EXEDBCONNECT ]
   then
-    MYPATH=`echo "$SAPSTARTDB" | head -1`
-    MYPATH=`dirname "$MYPATH"`
-    if [ -x $MYPATH/$EXESTARTDB -a -x $MYPATH/$EXESTOPDB -a -x $MYPATH/$EXEDBCONNECT ]
-    then
-      DIR_EXECUTABLE=$MYPATH
-      SAPSTARTDB=$MYPATH/$EXESTARTDB
-      SAPSTOPDB=$MYPATH/$EXESTOPDB
-      SAPDBCONNECT=$MYPATH/$EXEDBCONNECT
-      break
-    fi
+    DIR_EXECUTABLE=$EXEPATH
+    SAPSTARTDB=$EXEPATH/$EXESTARTDB
+    SAPSTOPDB=$EXEPATH/$EXESTOPDB
+    SAPDBCONNECT=$EXEPATH/$EXEDBCONNECT
+    break
   fi
 done
 if [ -z "$DIR_EXECUTABLE" ]
 then
-  ocf_log err "Cannot find $EXESTARTDB,$EXESTOPDB and $EXEDBCONNECT executable, please set DIR_EXECUTABLE parameter!"
-  exit $OCF_ERR_GENERIC
+  ocf_log warn "Cannot find $EXESTARTDB,$EXESTOPDB and $EXEDBCONNECT executable, please set DIR_EXECUTABLE parameter!"
+  exit $OCF_NOT_RUNNING
 fi
 
 if [ $DBJ2EE_ONLY -eq 1 ]
@@ -667,6 +934,39 @@ then
   else
     SECSTORE=/usr/sap/$SID/SYS/global/security/lib/tools
   fi
+
+  if [ -n "$OCF_RESKEY_JAVA_HOME" ]
+  then
+    JAVA_HOME="$OCF_RESKEY_JAVA_HOME"
+    PATH=$JAVA_HOME/bin:$PATH
+  else
+    if [ -n "$JAVA_HOME" ]
+    then
+      PATH=$JAVA_HOME/bin:$PATH
+    else
+      ocf_log err "Cannot find JAVA_HOME directory, please set JAVA_HOME parameter!"
+      exit $OCF_NOT_RUNNING
+    fi
+  fi
+
+  if [ -n "$OCF_RESKEY_DB_JARS" ]
+  then
+    DB_JARS=$OCF_RESKEY_DB_JARS
+  else
+    if [ -f "$BOOTSTRAP"/bootstrap.properties ]; then
+      DB_JARS=`cat $BOOTSTRAP/bootstrap.properties | grep -i rdbms.driverLocation | sed -e 's/\\\:/:/g' | awk -F= '{print $2}'`
+    fi
+  fi
+fi
+
+if [ -z "$OCF_RESKEY_AUTOMATIC_RECOVER" ]
+then
+  OCF_RESKEY_AUTOMATIC_RECOVER=0
+else
+  case "$OCF_RESKEY_AUTOMATIC_RECOVER" in
+   1|true|TRUE|yes|YES) OCF_RESKEY_AUTOMATIC_RECOVER=1;;
+   0|false|FALSE|no|NO) OCF_RESKEY_AUTOMATIC_RECOVER=0;;
+  esac
 fi
 
 # as root user we need the library path to the SAP kernel to be able to call executables
@@ -685,14 +985,14 @@ case "$1" in
 		exit $?;;
 
   monitor)
-          	sapdatabase_monitor
+          	sapdatabase_monitor $OCF_RESKEY_STRICT_MONITORING
 		exit $?;;
 
   status)
                 sapdatabase_status
                 exit $?;;
 
-  validate-all)	sapdatabase_vaildate
+  validate-all)	sapdatabase_validate
 		exit $?;;
 
   *)		sapdatabase_methods
diff --git a/rgmanager/src/resources/SAPInstance b/rgmanager/src/resources/SAPInstance
index 0ef2fd3..d04fcb3 100644
--- a/rgmanager/src/resources/SAPInstance
+++ b/rgmanager/src/resources/SAPInstance
@@ -9,33 +9,38 @@
 #               about essential services.
 #
 # Author:       Alexander Krauth, June 2006
-# Support:      liunx@sap.com
+# Support:      linux@sap.com
 # License:      GNU General Public License (GPL)
-# Copyright:    (c) 2006 Alexander Krauth
+# Copyright:    (c) 2006, 2007 Alexander Krauth
 #
 # An example usage: 
 #      See usage() function below for more details...
 #
 # OCF instance parameters:
 #	OCF_RESKEY_InstanceName
-#       OCF_RESKEY_DIR_EXECUTABLE   (optional, well known directories will be searched by default)
-#       OCF_RESKEY_DIR_PROFILE      (optional, well known directories will be searched by default)
-#       OCF_RESKEY_START_PROFILE    (optional, well known directories will be searched by default)
+#	OCF_RESKEY_DIR_EXECUTABLE   (optional, well known directories will be searched by default)
+#	OCF_RESKEY_DIR_PROFILE      (optional, well known directories will be searched by default)
+#	OCF_RESKEY_START_PROFILE    (optional, well known directories will be searched by default)
+#	OCF_RESKEY_START_WAITTIME   (optional, to solve timing problems during J2EE-Addin start)
+#	OCF_RESKEY_AUTOMATIC_RECOVER    (optional, automatic startup recovery using cleanipc, default is false)
+#	OCF_RESKEY_PRE_START_USEREXIT	(optional, lists a script which can be executed before the resource is started)
+#	OCF_RESKEY_POST_START_USEREXIT	(optional, lists a script which can be executed after the resource is started)
+#	OCF_RESKEY_PRE_STOP_USEREXIT	(optional, lists a script which can be executed before the resource is stopped)
+#	OCF_RESKEY_POST_STOP_USEREXIT	(optional, lists a script which can be executed after the resource is stopped)
 #
 #######################################################################
 # Initialization:
 
-if [ -f /usr/lib/heartbeat/ocf-shellfuncs ]; then
-	. /usr/lib/heartbeat/ocf-shellfuncs
+if [ -f ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs ]; then
+        . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
 elif [ -f /usr/share/cluster/ocf-shellfuncs ]; then
-	. /usr/share/cluster/ocf-shellfuncs
-elif [ -f `dirname $0`/ocf-shellfuncs ]; then
-	. `dirname $0`/ocf-shellfuncs
+        . /usr/share/cluster/ocf-shellfuncs
 else
-	echo Could not find ocf-shellfuncs!
-	exit 1
+        echo Could not find ocf-shellfuncs!
+        exit 1
 fi
 
+
 #######################################################################
 
 SH=/bin/sh
@@ -61,9 +66,9 @@ usage() {
 meta_data() {
 	cat <<END
 <?xml version="1.0"?>
-<!DOCTYPE resource-agent SYSTEM "ra-api-1-modified.dtd">
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
 <resource-agent name="SAPInstance">
-<version>1.6</version>
+<version>1.92</version>
 
 <longdesc lang="en">
 Resource script for SAP. It manages a SAP Instance as an HA resource.
@@ -71,32 +76,62 @@ Resource script for SAP. It manages a SAP Instance as an HA resource.
 <shortdesc lang="en">SAP instance resource agent</shortdesc>
 
 <parameters>
- <parameter name="InstanceName" unique="1" required="1" primary="1">
+ <parameter name="InstanceName" unique="1" required="1">
   <longdesc lang="en">The full qualified SAP instance name. e.g. P01_DVEBMGS00_sapp01ci</longdesc>
   <shortdesc lang="en">instance name: SID_INSTANCE_VIR-HOSTNAME</shortdesc>
   <content type="string" default="" />
  </parameter>
- <parameter name="DIR_EXECUTABLE" unique="1" required="0">
+ <parameter name="DIR_EXECUTABLE" unique="0" required="0">
   <longdesc lang="en">The full qualified path where to find sapstartsrv and sapcontrol.</longdesc>
   <shortdesc lang="en">path of sapstartsrv and sapcontrol</shortdesc>
   <content type="string" default="" />
  </parameter>
- <parameter name="DIR_PROFILE" unique="1" required="0">
+ <parameter name="DIR_PROFILE" unique="0" required="0">
   <longdesc lang="en">The full qualified path where to find the SAP START profile.</longdesc>
   <shortdesc lang="en">path of start profile</shortdesc>
   <content type="string" default="" />
  </parameter>
- <parameter name="START_PROFILE" unique="1" required="0">
+ <parameter name="START_PROFILE" unique="0" required="0">
   <longdesc lang="en">The name of the SAP START profile.</longdesc>
   <shortdesc lang="en">start profile name</shortdesc>
   <content type="string" default="" />
  </parameter>
+ <parameter name="START_WAITTIME" unique="0" required="0">
+  <longdesc lang="en">After that time in seconds a monitor operation is executed by the resource agent. Does the monitor return SUCCESS, the start is handled as SUCCESS. This is useful to resolve timing problems with e.g. the J2EE-Addin instance.</longdesc>
+  <shortdesc lang="en">Check the successful start after that time (do not wait for J2EE-Addin)</shortdesc>
+  <content type="string" default="3600" />
+ </parameter>
+ <parameter name="AUTOMATIC_RECOVER" unique="0" required="0">
+  <longdesc lang="en">The SAPInstance resource agent tries to recover a failed start attempt automaticaly one time. This is done by killing runing instance processes and executing cleanipc.</longdesc>
+  <shortdesc lang="en">Enable or disable automatic startup recovery</shortdesc>
+  <content type="boolean" default="false"/>
+ </parameter>
+ <parameter name="PRE_START_USEREXIT" unique="0" required="0">
+  <longdesc lang="en">The full qualified path where to find a script or program which should be executed before this resource gets started.</longdesc>
+  <shortdesc lang="en">path to a pre-start script</shortdesc>
+  <content type="string" default="" />
+ </parameter>
+ <parameter name="POST_START_USEREXIT" unique="0" required="0">
+  <longdesc lang="en">The full qualified path where to find a script or program which should be executed after this resource got started.</longdesc>
+  <shortdesc lang="en">path to a post-start script</shortdesc>
+  <content type="string" default="" />
+ </parameter>
+ <parameter name="PRE_STOP_USEREXIT" unique="0" required="0">
+  <longdesc lang="en">The full qualified path where to find a script or program which should be executed before this resource gets stopped.</longdesc>
+  <shortdesc lang="en">path to a pre-start script</shortdesc>
+  <content type="string" default="" />
+ </parameter>
+ <parameter name="POST_STOP_USEREXIT" unique="0" required="0">
+  <longdesc lang="en">The full qualified path where to find a script or program which should be executed after this resource got stopped.</longdesc>
+  <shortdesc lang="en">path to a post-start script</shortdesc>
+  <content type="string" default="" />
+ </parameter>
 </parameters>
 
 <actions>
 <action name="start" timeout="180" />
 <action name="stop" timeout="240" />
-<action name="status" timeout="60" />
+<action name="status" timeout="60" depth="0" interval="120" start-delay="240" />
 <action name="monitor" depth="0" timeout="60" interval="120" start-delay="240" />
 <action name="validate-all" timeout="5" />
 <action name="meta-data" timeout="5" />
@@ -131,6 +166,9 @@ sapinstance_methods() {
 #
 check_sapstartsrv() {
   restart=0
+  runninginst=""
+  chkrc=$OCF_SUCCESS
+
   output=`$SAPCONTROL -nr $InstanceNr -function ParameterValue INSTANCE_NAME -format script`
   if [ $? -eq 0 ]
   then
@@ -152,42 +190,154 @@ check_sapstartsrv() {
     pkill -9 -f "sapstartsrv.*$runninginst"
     $SAPSTARTSRV pf=$SAPSTARTPROFILE -D -u $sidadm
 
-    ocf_log info "sapstartsrv for instance $SID-$InstanceName was restarted !"
+    # now make sure the daemon has been started and is able to respond
+    srvrc=1
+    while [ $srvrc -eq 1 -a `pgrep -f "sapstartsrv.*$runninginst" | wc -l` -gt 0 ]
+    do
+      sleep 1
+      $SAPCONTROL -nr $InstanceNr -function GetProcessList > /dev/null 2>&1
+      srvrc=$?
+    done
+
+    if [ $srvrc -ne 1 ]
+    then
+      ocf_log info "sapstartsrv for instance $SID-$InstanceName was restarted !"
+      chkrc=$OCF_SUCCESS
+    else
+      ocf_log error "sapstartsrv for instance $SID-$InstanceName could not be started!"
+      chkrc=$OCF_NOT_RUNNING
+    fi
   fi
 
+  return $chkrc
+}
+
+
+#
+# sapuserexit : Many SAP customers need some additional processes/tools to run their SAP systems.
+#               This specialties do not allow a totally generic SAP cluster resource agent.
+#               Someone should write a resource agent for each additional process you need, if it
+#               is required to monitor that process within the cluster manager. To enable 
+#               you to extent this resource agent without developing a new one, this user exit
+#               was introduced.
+#
+sapuserexit() {
+  NAME="$1"
+  VALUE="$2"
+
+  if [ -n "$VALUE" ]
+  then
+    if [ -x "$VALUE" ]
+    then
+      ocf_log info "Calling userexit ${NAME} with customer script file ${VALUE}"
+      eval "$VALUE" >& /dev/null
+      ocf_log info "Exiting userexit ${NAME} with customer script file ${VALUE}, returncode: $?"
+    else
+      ocf_log warn "Attribute ${NAME} is set to ${VALUE}, but this file is not executable"
+    fi
+  fi
   return 0
 }
 
 
 #
+# cleanup_instance : remove resources (processes and shared memory) from a crashed instance)
+#
+cleanup_instance() {
+  pkill -9 -f -U $sidadm $InstanceName
+  $DIR_EXECUTABLE/cleanipc $InstanceNr remove
+  return 0
+}
+
+#
 # sapinstance_start : Start the SAP instance
 #
 sapinstance_start() {
-  check_sapstartsrv
 
-  output=`$SAPCONTROL -nr $InstanceNr -function Start`
-  if [ $? -eq 0 ]
-  then
-    output=`$SAPCONTROL -nr $InstanceNr -function WaitforStarted 3600 1`
-    if [ $? -eq 0 ]
+  sapuserexit PRE_START_USEREXIT "$OCF_RESKEY_PRE_START_USEREXIT"
+
+  rc=$OCF_NOT_RUNNING
+  loopcount=0
+  while [ $loopcount -lt 2 ]
+  do
+    loopcount=$(($loopcount + 1))
+
+    check_sapstartsrv
+    output=`$SAPCONTROL -nr $InstanceNr -function Start`
+    rc=$?
+    ocf_log info "Starting SAP Instance $SID-$InstanceName: $output"
+
+    if [ $rc -ne 0 ]
     then
-      ocf_log info "SAP Instance $SID-$InstanceName started: $output"
-      rc=$OCF_SUCCESS
-    else
-      ocf_log err "SAP Instance $SID-$InstanceName start failed: $output"
-      rc=$OCF_ERR_GENERIC
+      ocf_log err "SAP Instance $SID-$InstanceName start failed."
+      return $OCF_ERR_GENERIC
     fi
+
+    startrc=1
+    while [ $startrc -gt 0 ]
+    do
+      waittime_start=`date +%s`
+      output=`$SAPCONTROL -nr $InstanceNr -function WaitforStarted $OCF_RESKEY_START_WAITTIME 10`
+      startrc=$?
+      waittime_stop=`date +%s`
+
+      if [ $startrc -ne 0 ]
+      then
+        if [ $(($waittime_stop - $waittime_start)) -ge $OCF_RESKEY_START_WAITTIME ]
+        then
+          sapinstance_monitor NOLOG
+          if [ $? -eq $OCF_SUCCESS ]
+          then
+            output="START_WAITTIME ($OCF_RESKEY_START_WAITTIME) has elapsed, but instance monitor returned SUCCESS. Instance considered running."
+            startrc=0; loopcount=2
+          fi
+        else
+          if [ $loopcount -eq 1 -a $OCF_RESKEY_AUTOMATIC_RECOVER -eq 1 ]
+          then
+            ocf_log warn "SAP Instance $SID-$InstanceName start failed: $output"
+            ocf_log warn "Try to recover $SID-$InstanceName"
+            cleanup_instance
+          else
+            loopcount=2
+          fi
+          startrc=-1
+        fi
+      else
+        loopcount=2
+      fi
+    done
+  done
+
+  if [ $startrc -eq 0 ]
+  then
+    ocf_log info "SAP Instance $SID-$InstanceName started: $output"
+    rc=$OCF_SUCCESS
+    sapuserexit POST_START_USEREXIT "$OCF_RESKEY_POST_START_USEREXIT"
   else
     ocf_log err "SAP Instance $SID-$InstanceName start failed: $output"
-    rc=$OCF_ERR_GENERIC
+    rc=$OCF_NOT_RUNNING
   fi
+
   return $rc
 }
 
+
+#
+# sapinstance_recover: Try startup of failed instance by cleaning up resources
+#
+sapinstance_recover() {
+  cleanup_instance
+  sapinstance_start
+  return $?
+}
+
+
 #
 # sapinstance_stop: Stop the SAP instance
 #
 sapinstance_stop() {
+  sapuserexit PRE_STOP_USEREXIT "$OCF_RESKEY_PRE_STOP_USEREXIT"
+
   check_sapstartsrv
 
   output=`$SAPCONTROL -nr $InstanceNr -function Stop`
@@ -206,6 +356,9 @@ sapinstance_stop() {
     ocf_log err "SAP Instance $SID-$InstanceName stop failed: $output"
     rc=$OCF_ERR_GENERIC
   fi
+
+  sapuserexit POST_STOP_USEREXIT "$OCF_RESKEY_POST_STOP_USEREXIT"
+
   return $rc
 }
 
@@ -214,50 +367,60 @@ sapinstance_stop() {
 # sapinstance_monitor: Can the given SAP instance do anything useful?
 #
 sapinstance_monitor() {
+  MONLOG=$1
   check_sapstartsrv
+  rc=$?
 
-  rc=$OCF_SUCCESS
-  count=0
-  LOCALHOST=`hostname`
-  output=`$SAPCONTROL -nr $InstanceNr -host $LOCALHOST -function GetProcessList -format script`
-
-  # we have to parse the output, because the returncode doesn't tell anything about the instance status
-  for SERVNO in `echo "$output" | grep '^[0-9] ' | cut -d' ' -f1 | sort -u`
-  do
-    COLOR=`echo "$output" | grep "^$SERVNO dispstatus: " | cut -d' ' -f3`
-    SERVICE=`echo "$output" | grep "^$SERVNO name: " | cut -d' ' -f3`
-    STATE=0
-
-    case $COLOR in
-      GREEN|YELLOW)       STATE=$OCF_SUCCESS;;
-      *)                  STATE=$OCF_NOT_RUNNING;;
-    esac 
-
-    case $SERVICE in
-      disp+work|msg_server|enserver|enrepserver)
-                    if [ $STATE -eq $OCF_NOT_RUNNING ]
-                    then
-                      ocf_log err "SAP instance service $SERVICE is not running with status $COLOR !"
-                      rc=$STATE
-                    fi
-                    count=1;;
-      *);;
-    esac
-  done
-
-  if [ $count -eq 0 -a $rc -eq $OCF_SUCCESS ]
+  if [ $rc -eq $OCF_SUCCESS ]
   then
-    ocf_log err "The SAP instance does not run any services which this RA could monitor!"
-    rc=$OCF_ERR_ARGS
+    count=0
+    LOCALHOST=`hostname`
+    output=`$SAPCONTROL -nr $InstanceNr -host $LOCALHOST -function GetProcessList -format script`
+
+    # we have to parse the output, because the returncode doesn't tell anything about the instance status
+    for SERVNO in `echo "$output" | grep '^[0-9] ' | cut -d' ' -f1 | sort -u`
+    do
+      COLOR=`echo "$output" | grep "^$SERVNO dispstatus: " | cut -d' ' -f3`
+      SERVICE=`echo "$output" | grep "^$SERVNO name: " | cut -d' ' -f3`
+      STATE=0
+
+      case $COLOR in
+        GREEN|YELLOW)       STATE=$OCF_SUCCESS;;
+        *)                  STATE=$OCF_NOT_RUNNING;;
+      esac 
+
+      case $SERVICE in
+        disp+work|msg_server|enserver|enrepserver|jcontrol|jstart)
+                      if [ $STATE -eq $OCF_NOT_RUNNING ]
+                      then
+                        if [ "$MONLOG" != "NOLOG" ]
+                        then
+                          ocf_log err "SAP instance service $SERVICE is not running with status $COLOR !"
+                        fi
+                        rc=$STATE
+                      fi
+                      count=1;;
+        *);;
+      esac
+    done
+
+    if [ $count -eq 0 -a $rc -eq $OCF_SUCCESS ]
+    then
+      if [ "$MONLOG" != "NOLOG" ]
+      then
+        ocf_log err "The SAP instance does not run any services which this RA could monitor!"
+      fi
+      rc=$OCF_ERR_ARGS
+    fi
   fi
-
+  
   return $rc
 }
 
 #
-# sapinstance_vaildate: Check the symantic of the input parameters 
+# sapinstance_validate: Check the symantic of the input parameters 
 #
-sapinstance_vaildate() {
+sapinstance_validate() {
   rc=$OCF_SUCCESS
   if [ `echo "$SID" | grep -c '^[A-Z][A-Z0-9][A-Z0-9]$'` -ne 1 ]
   then
@@ -347,8 +510,8 @@ then
     SAPSTARTSRV="/usr/sap/$SID/SYS/exe/run/sapstartsrv"
     SAPCONTROL="/usr/sap/$SID/SYS/exe/run/sapcontrol"
   else
-    ocf_log err "Cannot find sapstartsrv and sapcontrol executable, please set DIR_EXECUTABLE parameter!"
-    exit $OCF_ERR_GENERIC
+    ocf_log warn "Cannot find sapstartsrv and sapcontrol executable, please set DIR_EXECUTABLE parameter!"
+    exit $OCF_NOT_RUNNING
   fi
 else
   DIR_EXECUTABLE="$OCF_RESKEY_DIR_EXECUTABLE"
@@ -362,8 +525,8 @@ then
   then
     DIR_PROFILE="/usr/sap/$SID/SYS/profile"
   else
-    ocf_log err "Expected /usr/sap/$SID/SYS/profile/ to be a directory, please set DIR_PROFILE parameter!"
-    exit $OCF_ERR_GENERIC
+    ocf_log warn "Expected /usr/sap/$SID/SYS/profile/ to be a directory, please set DIR_PROFILE parameter!"
+    exit $OCF_NOT_RUNNING
   fi
 else
   DIR_PROFILE="$OCF_RESKEY_DIR_PROFILE"
@@ -374,13 +537,29 @@ then
   SAPSTARTPROFILE="$DIR_PROFILE/START_${InstanceName}_${SAPVIRHOST}"
   if [ ! -r $SAPSTARTPROFILE ]
   then
-    ocf_log err "Expected $SAPSTARTPROFILE to be the instance START profile, please set START_PROFILE parameter!"
-    exit $OCF_ERR_GENERIC
+    ocf_log warn "Expected $SAPSTARTPROFILE to be the instance START profile, please set START_PROFILE parameter!"
+    exit $OCF_NOT_RUNNING
   fi
 else
   SAPSTARTPROFILE="$OCF_RESKEY_START_PROFILE"
 fi
 
+if [ -z "$OCF_RESKEY_START_WAITTIME" ]
+then
+  OCF_RESKEY_START_WAITTIME=3600
+fi
+
+
+if [ -z "$OCF_RESKEY_AUTOMATIC_RECOVER" ]
+then
+  OCF_RESKEY_AUTOMATIC_RECOVER=0
+else
+  case "$OCF_RESKEY_AUTOMATIC_RECOVER" in
+   1|true|TRUE|yes|YES) OCF_RESKEY_AUTOMATIC_RECOVER=1;;
+   0|false|FALSE|no|NO) OCF_RESKEY_AUTOMATIC_RECOVER=0;;
+  esac
+fi
+
 # as root user we need the library path to the SAP kernel to be able to call sapcontrol
 if [ `echo $LD_LIBRARY_PATH | grep -c "^$DIR_EXECUTABLE\>"` -eq 0 ]; then
   LD_LIBRARY_PATH=$DIR_EXECUTABLE:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
@@ -400,7 +579,7 @@ case "$1" in
           	sapinstance_monitor
 		exit $?;;
 
-  validate-all)	sapinstance_vaildate
+  validate-all)	sapinstance_validate
 		exit $?;;
 
   *)		sapinstance_methods


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]