<longdesc lang="en">
Resource script for SAP databases. It manages a SAP database of any type as an HA resource.
</longdesc>
-<shortdesc lang="en">SAP database resource agent</shortdesc>
+<shortdesc lang="en">Manages any SAP database (based on Oracle, MaxDB, or DB2)</shortdesc>
<parameters>
<parameter name="SID" unique="1" required="1" primary="1">
@@ -201,26 +201,27 @@ do_exit() {
# listener_start: Start the given listener
#
listener_start() {
- orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
- rc=$OCF_SUCCESS
+ local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
+ local lrc=$OCF_SUCCESS
+ local output
output=`echo "lsnrctl start $NETSERVICENAME" | su - $orasid 2>&1`
if [ $? -eq 0 ]
then
ocf_log info "Oracle Listener $NETSERVICENAME started: $output"
- rc=$OCF_SUCCESS
+ lrc=$OCF_SUCCESS
else
ocf_log err "Oracle Listener $NETSERVICENAME start failed: $output"
- rc=$OCF_ERR_GENERIC
+ lrc=$OCF_ERR_GENERIC
fi
- return $rc
+ return $lrc
}
#
# listener_stop: Stop the given listener
#
listener_stop() {
- orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
- rc=$OCF_SUCCESS
+ local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
+ local lrc=$OCF_SUCCESS
if
listener_status
then
@@ -228,84 +229,89 @@ listener_stop() {
else
return $OCF_SUCCESS
fi
+ local output
output=`echo "lsnrctl stop $NETSERVICENAME" | su - $orasid 2>&1`
if [ $? -eq 0 ]
then
ocf_log info "Oracle Listener $NETSERVICENAME stopped: $output"
else
ocf_log err "Oracle Listener $NETSERVICENAME stop failed: $output"
- rc=$OCF_ERR_GENERIC
+ lrc=$OCF_ERR_GENERIC
fi
- return $rc
+ return $lrc
}
#
# listener_status: is the given listener running?
#
listener_status() {
- orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
+ local lrc=$OCF_SUCCESS
+ local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
# 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 $orasid | grep $NETSERVICENAME | grep -c tnslsnr`
+ local cnt=`ps efo args --user $orasid | grep $NETSERVICENAME | grep -c tnslsnr`
if [ $cnt -eq 1 ]
then
- rc=$OCF_SUCCESS
+ lrc=$OCF_SUCCESS
else
ocf_log info "listener process not running for $NETSERVICENAME for $SID"
- rc=$OCF_ERR_GENERIC
+ lrc=$OCF_ERR_GENERIC
fi
- return $rc
+ return $lrc
}
#
# x_server_start: Start the given x_server
#
x_server_start() {
- rc=$OCF_SUCCESS
+ local rc=$OCF_SUCCESS
+ local output
output=`echo "x_server start" | su - $sidadm 2>&1`
if [ $? -eq 0 ]
then
ocf_log info "MaxDB x_server start: $output"
- rc=$OCF_SUCCESS
+ lrc=$OCF_SUCCESS
else
ocf_log err "MaxDB x_server start failed: $output"
- rc=$OCF_ERR_GENERIC
+ lrc=$OCF_ERR_GENERIC
fi
- return $rc
+ return $lrc
}
#
# x_server_stop: Stop the x_server
#
x_server_stop() {
- rc=$OCF_SUCCESS
+ local lrc=$OCF_SUCCESS
+ local output
output=`echo "x_server stop" | su - $sidadm 2>&1`
if [ $? -eq 0 ]
then
ocf_log info "MaxDB x_server stop: $output"
else
ocf_log err "MaxDB x_server stop failed: $output"
- rc=$OCF_ERR_GENERIC
+ lrc=$OCF_ERR_GENERIC
fi
- return $rc
+ return $lrc
}
#
# x_server_status: is the x_server running?
#
x_server_status() {
- sdbuser=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
+ local lrc=$OCF_SUCCESS
+ local 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`
+ local cnt=`ps efo args --user $sdbuser | grep -c vserver`
if [ $cnt -ge 1 ]
then
- rc=$OCF_SUCCESS
+ lrc=$OCF_SUCCESS
else
ocf_log info "x_server process not running"
- rc=$OCF_ERR_GENERIC
+ lrc=$OCF_ERR_GENERIC
fi
- return $rc
+ return $lrc
}
@@ -768,7 +781,7 @@ sapdatabase_status() {
then
rc=$OCF_SUCCESS
else
- # ocf_log info "Database Instance $SID is not running on `hostname`"
+ ocf_log err "Database Instance $SID is not running on `hostname`"
rc=$OCF_NOT_RUNNING
fi
return $rc
@@ -876,7 +889,7 @@ if [ -z "$OCF_RESKEY_DBTYPE" ]; then
ocf_log err "Please set OCF_RESKEY_DBTYPE to the database vendor specific tag (ORA,ADA,DB6)!"
do_exit $OCF_ERR_ARGS
fi
-DBTYPE=`echo "$OCF_RESKEY_DBTYPE" | tr '[a-z]' '[A-Z]'`
+DBTYPE=`echo "$OCF_RESKEY_DBTYPE" | tr "[a-z]" "[A-Z]"`
# optional OCF parameters, we try to guess which directories are correct
EXESTARTDB="startdb"
@@ -947,7 +960,7 @@ then
then
BOOTSTRAP="$OCF_RESKEY_DIR_BOOTSTRAP"
else
- BOOTSTRAP=`echo /usr/sap/$SID/*/j2ee/cluster/bootstrap | head -1`
+ BOOTSTRAP=`ls -1d /usr/sap/$SID/*/j2ee/cluster/bootstrap | head -1`
fi