Hi Dejan,
Here's the output from the new oracle RA :

 # ./oracle showdbstat
Full output:
ENV MSG: Server Express environment enabled
SP2-0640: Not connected
Stripped output:
<ENV MSG: Server Express environment enabled
OPEN>

I also turned debug and verbose on and reran the oracle RA.  The output is 
attached as showdbstat.txt

If there is anything else you want me to try, let me know.

Bernie.

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Dejan Muhamedagic
Sent: Tuesday, September 15, 2009 6:36 AM
To: General Linux-HA mailing list
Subject: Re: [Linux-HA] Where can I get a more update version of 
ocf:oracle/oralsnr scripts

Hi Bernie,

On Mon, Sep 14, 2009 at 03:46:14PM -0400, Bernie Wu wrote:
> Hi Dejan,
>
> Here's one of the output from "select status from v$instance" ;
> lnodbct:/appl01/app/oracle[dssd] sqlplus 'sys as sysdba'
>
> SQL*Plus: Release 10.2.0.4.0 - Production on Mon Sep 14 15:42:25 2009
>
> Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
>
> Enter password:
>
> Connected to:
> Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
> With the Partitioning, OLAP, Data Mining and Real Application Testing options
>
> SQL> select status from v$instance;
>
> STATUS
> ------------
> OPEN
>
> SQL>

Thanks for the output, but I'd actually need that with some sets
beforehand, sorry about not being more specific. You should
simulated what the oracle RA does (the dbasql() function):

    connect / as sysdba
    set feedback off
    set heading off
    set pagesize 0

It's important that the output is stripped of everything but the
actual result. If that can't be done, then more changes are
needed. I just implemented a new action showdbstat which you may
use to print what I need. You'll just have to run the script from
the command line:

# export OCF_ROOT=/usr/lib/ocf
# OCF_RESKEY_sid=YOURSID .../oracle showdbstat

Get the new RA from http://hg.linux-ha.org/agents.

BTW, you can run the new script from any location, i.e. you don't
have to overwrite the existing oracle RA.

Thanks,

Dejan


> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Dejan Muhamedagic
> Sent: Monday, September 14, 2009 1:27 PM
> To: General Linux-HA mailing list
> Subject: Re: [Linux-HA] Where can I get a more update version of 
> ocf:oracle/oralsnr scripts
>
> Hi,
>
> On Mon, Sep 14, 2009 at 10:48:15AM -0400, Bernie Wu wrote:
> > The oralsnr script is OK.
> > It is the oracle script that I had to modify.
> >
> > Here's the diff for oracle:
> >
> > 418c418,419
> > <       [ "`dbasql dbstat`" = OPEN ]
> > ---
> > >     output="`dbasql dbstat`"
> > >     echo "$output" | tail -1 | grep -qs '^OPEN'
>
> > 454c455
> > <               status="`dbasql dbstat`"
> > ---
> > >               status="`dbasql dbstat | tail -1 | egrep 
> > > '^OPEN|^STARTED|^MOUNTED' ` "
> > 482c483,484
> > <       status="`dbasql dbstat`"
> > ---
> > >       status="`dbasql dbstat | tail -1 | grep '^MOUNTED' `"
>
> Hmm, where are the extra thirty or so (482-454) lines? :)
>
> Can you please provide the sample output of the sql dbstat
> command: select status from v$instance;
>
> And the Oracle release. Obviously Oracle changed the output.
>
> Thanks,
>
> Dejan
>
> > -----Original Message-----
> > From: [email protected] 
> > [mailto:[email protected]] On Behalf Of Dejan Muhamedagic
> > Sent: Monday, September 14, 2009 7:08 AM
> > To: General Linux-HA mailing list
> > Subject: Re: [Linux-HA] Where can I get a more update version of 
> > ocf:oracle/oralsnr scripts
> >
> > Hi,
> >
> > On Fri, Sep 11, 2009 at 03:14:18PM -0400, Bernie Wu wrote:
> > > Hi List,
> > > Where can I get a more update version of ocf:oracle and
> > > ocf:oralsnr startup/shutdown script.  The version that came
> > > with Heartbeat 2.1.3 needs a lot of modifications to get it to
> > > work.
> >
> > The newest versions are at hg.linux-ha.org/agents.
> >
> > IIRC, neither of oracle RAs were changed much. Which
> > modifications do you have to make?
> >
> > Thanks,
> >
> > Dejan
> >
> > >
> > > TIA
> > > Bernie
> > >
> > > ________________________________
> > > The information contained in this e-mail message is intended only for the 
> > > personal and confidential use of the recipient(s) named above. This 
> > > message may be an attorney-client communication and/or work product and 
> > > as such is privileged and confidential. If the reader of this message is 
> > > not the intended recipient or an agent responsible for delivering it to 
> > > the intended recipient, you are hereby notified that you have received 
> > > this document in error and that any review, dissemination, distribution, 
> > > or copying of this message is strictly prohibited. If you have received 
> > > this communication in error, please notify us immediately by e-mail, and 
> > > delete the original message.
> > > _______________________________________________
> > > Linux-HA mailing list
> > > [email protected]
> > > http://lists.linux-ha.org/mailman/listinfo/linux-ha
> > > See also: http://linux-ha.org/ReportingProblems
> > _______________________________________________
> > Linux-HA mailing list
> > [email protected]
> > http://lists.linux-ha.org/mailman/listinfo/linux-ha
> > See also: http://linux-ha.org/ReportingProblems
> >
> > The information contained in this e-mail message is intended only for the 
> > personal and confidential use of the recipient(s) named above. This message 
> > may be an attorney-client communication and/or work product and as such is 
> > privileged and confidential. If the reader of this message is not the 
> > intended recipient or an agent responsible for delivering it to the 
> > intended recipient, you are hereby notified that you have received this 
> > document in error and that any review, dissemination, distribution, or 
> > copying of this message is strictly prohibited. If you have received this 
> > communication in error, please notify us immediately by e-mail, and delete 
> > the original message.
> > _______________________________________________
> > Linux-HA mailing list
> > [email protected]
> > http://lists.linux-ha.org/mailman/listinfo/linux-ha
> > See also: http://linux-ha.org/ReportingProblems
> _______________________________________________
> Linux-HA mailing list
> [email protected]
> http://lists.linux-ha.org/mailman/listinfo/linux-ha
> See also: http://linux-ha.org/ReportingProblems
>
> The information contained in this e-mail message is intended only for the 
> personal and confidential use of the recipient(s) named above. This message 
> may be an attorney-client communication and/or work product and as such is 
> privileged and confidential. If the reader of this message is not the 
> intended recipient or an agent responsible for delivering it to the intended 
> recipient, you are hereby notified that you have received this document in 
> error and that any review, dissemination, distribution, or copying of this 
> message is strictly prohibited. If you have received this communication in 
> error, please notify us immediately by e-mail, and delete the original 
> message.
> _______________________________________________
> Linux-HA mailing list
> [email protected]
> http://lists.linux-ha.org/mailman/listinfo/linux-ha
> See also: http://linux-ha.org/ReportingProblems
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

The information contained in this e-mail message is intended only for the 
personal and confidential use of the recipient(s) named above. This message may 
be an attorney-client communication and/or work product and as such is 
privileged and confidential. If the reader of this message is not the intended 
recipient or an agent responsible for delivering it to the intended recipient, 
you are hereby notified that you have received this document in error and that 
any review, dissemination, distribution, or copying of this message is strictly 
prohibited. If you have received this communication in error, please notify us 
immediately by e-mail, and delete the original message.
# 
# oracle
#
# Description:  Manages an Oracle Database as a High-Availability
#               resource
#
#
# Author:       Dejan Muhamedagic
# Support:      [email protected]
# License:      GNU General Public License (GPL)
# Copyright:    (C) 2006 International Business Machines, Inc.
#
#               This code inspired by the DB2 resource script
#               written by Alan Robertson
#
# An example usage in /etc/ha.d/haresources: 
#       node1  10.0.0.170 oracle::RK1::/oracle/10.2::orark1
#
# See usage() function below for more details...
#
# OCF instance parameters:
#       OCF_RESKEY_sid
#       OCF_RESKEY_home (optional; else read it from /etc/oratab)
#       OCF_RESKEY_user (optional; figure it out by checking file ownership)
#       OCF_RESKEY_ipcrm (optional; defaults to "instance")
#       OCF_RESKEY_clear_backupmode (optional; default to "false")
#       OCF_RESKEY_shutdown_method (optional; default to "checkpoint/abort")
#
# Initialization:

. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
+ . /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs
#
#
#       Common helper functions for the OCF Resource Agents supplied by
#       heartbeat.
#
# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée
#                    All Rights Reserved.
#
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# 


# TODO: Some of this should probably split out into a generic OCF
# library for shell scripts, but for the time being, we'll just use it
# ourselves...
#

# TODO wish-list:
# - Generic function for evaluating version numbers
# - Generic function(s) to extract stuff from our own meta-data
# - Logging function which automatically adds resource identifier etc
#   prefixes
# TODO: Move more common functionality for OCF RAs here.
#

# This was common throughout all legacy Heartbeat agents
unset LC_ALL; export LC_ALL
++ unset LC_ALL
++ export LC_ALL
unset LANGUAGE; export LANGUAGE
++ unset LANGUAGE
++ export LANGUAGE

__SCRIPT_NAME=`basename $0`
basename $0
+++ basename ./oracle
++ __SCRIPT_NAME=oracle
. /etc/ha.d/shellfuncs
++ . /etc/ha.d/shellfuncs
# Author:       Alan Robertson
# Support:      [email protected]
# License:      GNU Lesser General Public License (LGPL)
#
#       Set these variables if they're not already set...
#

prefix=/usr
+++ prefix=/usr
exec_prefix=/usr
+++ exec_prefix=/usr
: ${HA_DIR:=/etc/ha.d}
+++ : /etc/ha.d
: ${HA_RCDIR:=$HA_DIR/rc.d}
+++ : /etc/ha.d/rc.d
: ${HA_CONFDIR=$HA_DIR/conf}
+++ : /etc/ha.d/conf
: ${HA_CF:=$HA_DIR/ha.cf}
+++ : /etc/ha.d/ha.cf
: ${HA_VARLIB:=/var/lib/heartbeat}
+++ : /var/lib/heartbeat
: ${HA_RSCTMP:=/var/run/heartbeat/rsctmp}
+++ : /var/run/heartbeat/rsctmp
: ${HA_FIFO:=/var/lib/heartbeat/fifo}
+++ : /var/lib/heartbeat/fifo
: ${HA_BIN:=/usr/lib64/heartbeat}
+++ : /usr/lib64/heartbeat
: ${HA_NOARCHBIN:=/usr/share/heartbeat}
+++ : /usr/share/heartbeat
: ${HA_DATEFMT:="%Y/%m/%d_%T "}
+++ : '%Y/%m/%d_%T '
: ${HA_DEBUGLOG:=/dev/null}
+++ : /dev/null
: ${HA_RESOURCEDIR:=$HA_DIR/resource.d}
+++ : /etc/ha.d/resource.d
: ${HA_DOCDIR:=/usr/share/doc/heartbeat}
+++ : /usr/share/doc/heartbeat
: ${__SCRIPT_NAME:=`basename $0`}
+++ : oracle
: ${HA_LOGTAG:=$__SCRIPT_NAME[$$]}
+++ : 'oracle[12277]'
: ${HA_VARRUN:=/var/run/}
+++ : /var/run/
: ${HA_VARLOCK:=/var/lock/subsys/}
+++ : /var/lock/subsys/
: ${HA_SBIN_DIR:=/usr/sbin}
+++ : /usr/sbin

export HA_DIR HA_RCDIR HA_FIFO HA_BIN 
+++ export HA_DIR HA_RCDIR HA_FIFO HA_BIN
export HA_DEBUGLOG HA_LOGFILE HA_LOGFACILITY
+++ export HA_DEBUGLOG HA_LOGFILE HA_LOGFACILITY
export HA_DATEFMT HA_RESOURCEDIR HA_DOCDIR
+++ export HA_DATEFMT HA_RESOURCEDIR HA_DOCDIR

MKTEMP=/bin/mktemp
+++ MKTEMP=/bin/mktemp
TESTPROG=/usr/bin/test
+++ TESTPROG=/usr/bin/test
PATH=$HA_BIN:${HA_SBIN_DIR}:/usr/share/heartbeat:$PATH
+++ 
PATH=/usr/lib64/heartbeat:/usr/sbin:/usr/share/heartbeat:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
PATH=`echo $PATH | sed -e 's%::%%' -e 's%:\.:%:%' -e 's%^:%%' -e 's%^\.:%%'`
echo $PATH | sed -e 's%::%%' -e 's%:\.:%:%' -e 's%^:%%' -e 's%^\.:%%'
++++ echo 
/usr/lib64/heartbeat:/usr/sbin:/usr/share/heartbeat:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
++++ sed -e s%::%% -e 's%:\.:%:%' -e 's%^:%%' -e 's%^\.:%%'
+++ 
PATH=/usr/lib64/heartbeat:/usr/sbin:/usr/share/heartbeat:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
export PATH
+++ export PATH

#       A suitable echo command
Echo() {
  echo "$@"
}

hadate() {
  date "+${HA_DATEFMT}"
}

ha_log() {
        if [ "x${HA_LOGD}" = "xyes" ] ; then 
                ha_logger -t "${HA_LOGTAG}" "$@"
                if [ "$?" -eq "0" ] ; then
                        return 0
                fi
        fi

        if
          [ -n "$HA_LOGFACILITY" ]
        then
          : logging through syslog
          # loglevel is unknown, use 'notice' for now
          loglevel=notice
          case "${*}" in
            *ERROR*)            loglevel=err;;
            *WARN*)             loglevel=warning;;
            *INFO*|info)        loglevel=info;;
          esac
          logger -t "$HA_LOGTAG" -p ${HA_LOGFACILITY}.${loglevel} "${*}"
        fi      
        if
          [ -n "$HA_LOGFILE" ]
        then
          : appending to $HA_LOGFILE
          Echo "$HA_LOGTAG:     "`hadate`"${*}" >> $HA_LOGFILE
        else
          Echo `hadate`"${*}" >&2
        fi
        if
          [ -n "$HA_DEBUGLOG" ]
        then
          : appending to $HA_DEBUGLOG
          Echo "$HA_LOGTAG:     "`hadate`"${*}" >> $HA_DEBUGLOG
        fi
}

ha_debug() {

        if [ "x${HA_LOGD}" = "xyes" ] ; then  
                ha_logger -t "${HA_LOGTAG}" -D "ha-debug" "$@"
                if [ "$?" -eq "0" ] ; then
                        return 0
                fi
        fi

        if
          [ -n "$HA_LOGFACILITY" ]
        then
          : logging through syslog
          logger -t "$HA_LOGTAG" -p "${HA_LOGFACILITY}.debug" "${*}"
        fi
        if
          [ -n "$HA_DEBUGLOG" ]
        then
          : appending to $HA_DEBUGLOG
          Echo "$HA_LOGTAG:     "`hadate`"${*}" >> $HA_DEBUGLOG
        else
          Echo "$HA_LOGTAG:     `hadate`${*}:   ${HA_LOGFACILITY}" >&2
        fi
}

# copy stdin (text) to FIFO, with surrounding ">>>" and "<<<" marker lines.
# no args.; no result
# Notes:
#       o Using "cat -" rather than "cat" simply for clarity.
#       o The trailing "| cat -" tries to hold things together as a single
#         write (which is probably preferable behaviour in this context).
ha_clustermsg() {
        (echo ">>>"; cat -; echo "<<<") | cat - >> $HA_FIFO
}

ha_parameter() {
  VALUE=`sed -e 's%[    ][      ]*% %' -e 's%^ %%' -e 's%#.*%%'   $HA_CF |
  grep -i "^$1 " | sed 's%[^ ]* %%'`
  if
    [ "X$VALUE" = X ]
  then
    
    case $1 in
      keepalive)        VALUE=2;;
      deadtime)
                        ka=`ha_parameter keepalive`
                        VALUE=`expr $ka '*' 2 '+' 1`;;
    esac
  fi
  Echo $VALUE
}

BSD_Status() {
  local base=${1##*/}
  local pid

  ret_status=`/bin/ps -ao pid,command | grep $base | sed 's/ .*//'`

  if 
    [ "$ret_status" != "" ]
  then
    echo "${base} is running..."
  return 0
  fi

  if 
    [ -f $HA_VARRUN/${base}.pid ] 
  then
    echo "${base} dead but pid file exists"
    return 1
  fi

  if 
    [ -f /var/run/${base}.pid ] 
  then
    echo "${base} dead but pid file exists"
    return 1
  fi

  if 
    [ -f $HA_VARLOCK/var/lock/subsys/${base}.pid ] 
  then
    echo "${base} dead but lock file exists"
    return 2
  fi

  if 
    [ -f /var/spool/lock/${base} ] 
  then
    echo "${base} dead but lock file exists"
    return 2
  fi
}
#

#
# pseudo_resource status tracking function...
#
# This allows pseudo resources to give correct status information.  As we add
# resource monitoring, and better resource tracking in general, this will
# become essential.
#
# These scripts work because ${HA_RSCTMP} is cleaned out every time
# heartbeat is started.
#
# We create "resource-string" tracking files under ${HA_RSCTMP} in a
# very simple way:
#
#       Existence of "${HA_RSCTMP}/resource-string" means that we consider
#       the resource named by "resource-string" to be running.
#
# Note that "resource-string" needs to be unique.  Using the resource type
# plus the resource instance arguments to make up the resource string
# is probably sufficient...
#
# usage: ha_pseudo_resource resource-string op [tracking_file]
#       where op is {start|stop|monitor|status|restart|reload|print}
#       print is a special op which just prints the tracking file location
#       user can override our choice of the tracking file location by
#               specifying it as the third arg
#       Note that all operations are silent...
#
ha_pseudo_resource()
{
  ha_resource_tracking_file="${3:-${HA_RSCTMP}/$1}"
  case $2 in
    start|restart|reload)  touch "$ha_resource_tracking_file";;
    stop) rm -f "$ha_resource_tracking_file";;
    status|monitor)
           if
             [ -f "$ha_resource_tracking_file" ]
           then
             return 0
           else
             case $2 in
               status)  return 3;;
               *)       return 7;;
             esac
           fi;;
    print)  echo "$ha_resource_tracking_file";;
    *)  return 3;;
  esac
}

# Make temp files the paranoid way...
maketempfile() {
#
#       Use mktemp if we have it, otherwise...
#
#       Construct a difficult-to-guess filename if we don't
#       Make sure non-mktemp files can't be subverted
#       $RANDOM is not strictly necessary, but nice to have...
#
  if
    test "x$MKTEMP" != "x" \
      && F=`$MKTEMP /tmp/lha-XXXXXX` && [ ! -z "$F" -a -f "$F" ]
  then
    echo $F
  else
    while
      echo >/dev/null &
      F=/tmp/lha-${RANDOM}-$$-$!
      rm -f "$F"; touch "$F"
      # Try again if we don't own it, or it's a symlink
      # Or somehow not a regular file...
      $TESTPROG ! -O "$F" -o -L "$F" -o ! -f "$F"
    do
     : Try again...
    done
    echo $F
  fi
}

# The 'ping' command takes highly OS-dependent arguments, so this
# function creates a suitable argument list for the host OS's 'ping'.
# We use a subset of its functionality:
# 1. single packet
# 2. reasonable timeout (say 1 second)
#
# arguments:
#       $1: IP address to ping
# result string:
#       arguments for ping command
#
# If more flexibility is needed, they could be specified in the environment
# to this function, to adjust the resulting 'ping' arguments.
#       David Lee <[email protected]> May 2007
pingargs() {
        _baseip=$1
        _timeout=1      # seconds
        _pktcount=1
        _systype="`uname -s`"
        case $_systype in
                Linux)
                        # Default is perpetual ping: need "-c $_pktcount".
                        # -c count -t timetolive -q(uiet) -n(umeric) -W timeout
                        _pingargs="-c $_pktcount -q -n $_baseip"
                        ;;
                SunOS)
                        # Default is immediate (or timeout) return.
                        _pingargs="$_baseip $_timeout"
                        ;;
                *)
                        _pingargs="-c $_pktcount $_baseip"
                        ;;
        esac

        echo "$_pingargs"
}


if [ -z "$OCF_ROOT" ]; then
    : ${OCF_ROOT=/usr/lib/ocf}
fi
++ '[' -z /usr/lib/ocf ']'

. ${OCF_ROOT}/resource.d/heartbeat/.ocf-binaries
++ . /usr/lib/ocf/resource.d/heartbeat/.ocf-binaries
# Make sure PATH contains all the usual suspects
PATH="$PATH:/sbin:/bin:/usr/sbin:/usr/bin"
+++ 
PATH=/usr/lib64/heartbeat:/usr/sbin:/usr/share/heartbeat:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/sbin:/bin:/usr/sbin:/usr/bin

# Include /usr/ucb for finding whoami on Solaris
PATH="$PATH:/usr/ucb"
+++ 
PATH=/usr/lib64/heartbeat:/usr/sbin:/usr/share/heartbeat:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/ucb

export PATH
+++ export PATH

# Binaries and binary options for use in Resource Agents
: ${AWK:=/usr/bin/gawk}
+++ : /usr/bin/gawk
: ${EGREP:="/usr/bin/egrep"}
+++ : /usr/bin/egrep
: ${IFCONFIG_A_OPT:="-a"}
+++ : -a
: ${MAILCMD:=mailx}
+++ : mailx
: ${MKTEMP:=/bin/mktemp}
+++ : /bin/mktemp
: ${PING:=/bin/ping}
+++ : /bin/ping
: ${RPM:=/usr/bin/rpmbuild}
+++ : /usr/bin/rpmbuild
: ${SH:=/bin/sh}
+++ : /bin/sh
: ${TEST:=/usr/bin/test}
+++ : /usr/bin/test
: ${TESTPROG:=/usr/bin/test}
+++ : /usr/bin/test

# Entries that should probably be removed
: ${BASENAME:=basename}
+++ : basename
: ${BLOCKDEV:=blockdev}
+++ : blockdev
: ${CAT:=cat}
+++ : cat
: ${FSCK:=fsck}
+++ : fsck
: ${FUSER:=fuser}
+++ : fuser
: ${GETENT:=getent}
+++ : getent
: ${GREP:=grep}
+++ : grep
: ${IFCONFIG:=ifconfig}
+++ : ifconfig
: ${IPTABLES:=iptables}
+++ : iptables
: ${IP2UTIL:=ip}
+++ : ip
: ${MDADM:=mdadm}
+++ : mdadm
: ${MODPROBE:=modprobe}
+++ : modprobe
: ${MOUNT:=mount}
+++ : mount
: ${MSGFMT:=msgfmt}
+++ : msgfmt
: ${NETSTAT:=netstat}
+++ : netstat
: ${PERL:=perl}
+++ : perl
: ${PYTHON:=python}
+++ : python
: ${RAIDSTART:=raidstart}
+++ : raidstart
: ${RAIDSTOP:=raidstop}
+++ : raidstop
: ${ROUTE:=route}
+++ : route
: ${UMOUNT:=umount}
+++ : umount
: ${REBOOT:=reboot}
+++ : reboot
: ${POWEROFF_CMD:=poweroff}
+++ : poweroff
: ${WGET:=wget}
+++ : wget
: ${WHOAMI:=whoami}
+++ : whoami
: ${STRINGSCMD:=strings}
+++ : strings
: ${SCP:=scp}
+++ : scp
: ${SSH:=ssh}
+++ : ssh
: ${SWIG:=swig}
+++ : swig
: ${MKTEMP:=mktemp}
+++ : /bin/mktemp
: ${GZIP_PROG:=gzip}
+++ : gzip
: ${TAR:=tar}
+++ : tar
: ${MD5:=md5}
+++ : md5
: ${DRBDADM:=drbdadm}
+++ : drbdadm
: ${DRBDSETUP:=drbdsetup}
+++ : drbdsetup

check_binary () {
    if 
        have_binary "$1"
    then
        :
    else
        if [ $OCF_NOT_RUNNING = 7 ]; then
            # Chances are we have a fully setup OCF environment
            ocf_log err "Setup problem: Couldn't find utility $1"
        else 
            echo "Setup problem: Couldn't find utility $1"
        fi
        exit $OCF_ERR_INSTALLED
    fi
}

have_binary () {
    bin=`echo $1 | sed -e 's/ -.*//'`
    if [ -x "`which $bin`" ] >/dev/null 2>&1 ; then
        return 0
    fi
    return 1
}
. ${OCF_ROOT}/resource.d/heartbeat/.ocf-returncodes
++ . /usr/lib/ocf/resource.d/heartbeat/.ocf-returncodes
#
#       Common varibales for the OCF Resource Agents supplied by
#       heartbeat.
#
# Copyright (c) 2004 SUSE LINUX AG, Andrew Beekhof
#                    All Rights Reserved.
#
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# 

OCF_SUCCESS=0
+++ OCF_SUCCESS=0
OCF_ERR_GENERIC=1
+++ OCF_ERR_GENERIC=1
OCF_ERR_ARGS=2
+++ OCF_ERR_ARGS=2
OCF_ERR_UNIMPLEMENTED=3
+++ OCF_ERR_UNIMPLEMENTED=3
OCF_ERR_PERM=4
+++ OCF_ERR_PERM=4
OCF_ERR_INSTALLED=5
+++ OCF_ERR_INSTALLED=5
OCF_ERR_CONFIGURED=6
+++ OCF_ERR_CONFIGURED=6
OCF_NOT_RUNNING=7
+++ OCF_NOT_RUNNING=7

# Non-standard values.
#
# OCF does not include the concept of master/slave resources so we
#   need to extend it so we can discover a resource's complete state.
#
# OCF_RUNNING_MASTER:  
#    The resource is in "master" mode and fully operational
# OCF_FAILED_MASTER:
#    The resource is in "master" mode but in a failed state
# 
# The extra two values should only be used during a probe.
#
# Probes are used to discover resources that were started outside of
#    the CRM and/or left behind if the LRM fails.
# 
# They can be identified in RA scripts by checking for:
#   [ "${__OCF_ACTION}" = "monitor" -a "${OCF_RESKEY_CRM_meta_interval}" = "0" ]
# 
# Failed "slaves" should continue to use: OCF_ERR_GENERIC
# Fully operational "slaves" should continue to use: OCF_SUCCESS
#
OCF_RUNNING_MASTER=8
+++ OCF_RUNNING_MASTER=8
OCF_FAILED_MASTER=9
+++ OCF_FAILED_MASTER=9
. ${OCF_ROOT}/resource.d/heartbeat/.ocf-directories
++ . /usr/lib/ocf/resource.d/heartbeat/.ocf-directories
# Binaries and binary options for use in Resource Agents

prefix=/usr
+++ prefix=/usr
exec_prefix=/usr
+++ exec_prefix=/usr
: ${INITDIR:=/etc/init.d}
+++ : /etc/init.d
: ${HA_DIR:=/etc/ha.d}
+++ : /etc/ha.d
: ${HA_RCDIR:=$HA_DIR/rc.d}
+++ : /etc/ha.d/rc.d
: ${HA_CONFDIR=$HA_DIR/conf}
+++ : /etc/ha.d/conf
: ${HA_CF:=$HA_DIR/ha.cf}
+++ : /etc/ha.d/ha.cf
: ${HA_VARLIB:=/var/lib/heartbeat}
+++ : /var/lib/heartbeat
: ${HA_RSCTMP:=/var/run/heartbeat/rsctmp}
+++ : /var/run/heartbeat/rsctmp
: ${HA_FIFO:=/var/lib/heartbeat/fifo}
+++ : /var/lib/heartbeat/fifo
: ${HA_BIN:=/usr/lib64/heartbeat}
+++ : /usr/lib64/heartbeat
: ${HA_SBIN_DIR:=/usr/sbin}
+++ : /usr/sbin
: ${HA_DATEFMT:="%Y/%m/%d_%T "}
+++ : %Y/%m/%d_%T
: ${HA_DEBUGLOG:=/dev/null}
+++ : /dev/null
: ${HA_RESOURCEDIR:=$HA_DIR/resource.d}
+++ : /etc/ha.d/resource.d
: ${HA_DOCDIR:=/usr/share/doc/heartbeat}
+++ : /usr/share/doc/heartbeat
: ${__SCRIPT_NAME:=`basename $0`}
+++ : oracle
: ${HA_LOGTAG:=$__SCRIPT_NAME[$$]}
+++ : 'oracle[12277]'
: ${HA_VARRUN:=/var/run/}
+++ : /var/run/
: ${HA_VARLOCK:=/var/lock/subsys/}
+++ : /var/lock/subsys/

ocf_is_root() {
        case `id` in
          *'uid=0(root)'*)      true;;
          *)                    false;;
        esac
}

# Portability comments:
# o The following rely on Bourne "sh" pattern-matching, which is usually
#   that for filename generation (note: not regexp).
# o The "*) true ;;" clause is probably unnecessary, but is included
#   here for completeness.
# o The negation in the pattern uses "!".  This seems to be common
#   across many OSes (whereas the alternative "^" fails on some).
# o If an OS is encountered where this negation fails, then a possible
#   alternative would be to replace the function contents by (e.g.):
#       [ -z "`echo $1 | tr -d '[0-9]'`" ]
#
ocf_is_decimal() {
        case "$1" in
        ""|*[!0-9]*)    # empty, or at least one non-decimal
                false ;;
        *)
                true ;;
        esac
}

ocf_is_hex() {
        case "$1" in
        ""|*[!0-9a-fA-F]*)      # empty, or at least one non-hex
                false ;;
        *)
                true ;;
        esac
}

ocf_is_octal() {
        case "$1" in
        ""|*[!0-7]*)    # empty, or at least one non-octal
                false ;;
        *)
                true ;;
        esac
}

__ocf_set_defaults() {
        __OCF_ACTION="$1"

        # Return to sanity for the agents...
        unset LANG
        LC_ALL=C
        export LC_ALL

        # TODO: Review whether we really should source this. Or rewrite
        # to match some emerging helper function syntax...? This imports
        # things which no OCF RA should be using...

        # Strip the OCF_RESKEY_ prefix from this particular parameter
        if [ -z "$OCF_RESKEY_OCF_CHECK_LEVEL" ]; then
                : ${OCF_CHECK_LEVEL:=0}
        else
                : ${OCF_CHECK_LEVEL:=$OCF_RESKEY_OCF_CHECK_LEVEL}
        fi

        if [ ! -d "$OCF_ROOT" ]; then
                ha_log "ERROR: OCF_ROOT points to non-directory $OCF_ROOT."
                exit $OCF_ERR_GENERIC
        fi

        if [ -z "$OCF_RESOURCE_TYPE" ]; then
                : ${OCF_RESOURCE_TYPE:=$__SCRIPT_NAME}
        fi

        if [ -z "$OCF_RA_VERSION_MAJOR" ]; then
                : We are being invoked as an init script.
                : Fill in some things with reasonable values.
                : ${OCF_RESOURCE_INSTANCE:="default"}
                return 0
        fi

        if [ "x$__OCF_ACTION" = "xmeta-data" ]; then
                OCF_RESOURCE_INSTANCE="undef"
        fi      

        if [ -z "$OCF_RESOURCE_INSTANCE" ]; then
                ha_log "ERROR: Need to tell us our resource instance name."
                exit $OCF_ERR_ARGS
        fi
}

ocf_log() {
        # TODO: Revisit and implement internally.
        if
          [ $# -lt 2 ]
        then
          ocf_log err "Not enough arguments [$#] to ocf_log."
        fi
        __OCF_PRIO="$1"
        shift
        __OCF_MSG="$*"

        case "${__OCF_PRIO}" in
          crit) __OCF_PRIO="CRIT";;
          err)  __OCF_PRIO="ERROR";;
          warn) __OCF_PRIO="WARNING";;
          info) __OCF_PRIO="INFO";;
          debug)__OCF_PRIO="DEBUG";;
          *)    __OCF_PRIO=`echo ${__OCF_PRIO}| tr '[a-z]' '[A-Z]'`;;
        esac

        if [ "${__OCF_PRIO}" = "DEBUG" ]; then
                ha_debug "${__OCF_PRIO}: $__OCF_MSG"
        else
                ha_log "${__OCF_PRIO}: $__OCF_MSG"
        fi
}

#
# Ocf_run: Run a script, and log its output.
# Usage:   ocf_run <command>
#
ocf_run() {
        output=`"$@" 2>&1`
        rc=$?
        output=`echo $output`
        if [ $rc -eq 0 ]; then 
            if [ ! -z "$output" ]; then
                ocf_log info "$output"
            fi
            return $OCF_SUCCESS
        else
            if [ ! -z "$output" ]; then
                ocf_log err "$output"
            else
                ocf_log err "command failed: $*"
            fi
            return $OCF_ERR_GENERIC
        fi
}

ocf_pidfile_status() {
    pidfile=$1
    if [ ! -e $pidfile ]; then
        # Not exists
        return 2
    fi
    pid=`cat $pidfile`
    kill -0 $pid 2>&1 > /dev/null
    if [ $? = 0 ]; then
        return 0
    fi

    # Stale
    return 1
}

ocf_take_lock() {
    lockfile=$1

    if [ ! -n $RANDOM ]; then
        # Something sane-ish in case a shell doesn't support $RANDOM
        RANDOM=$$
    fi

    sleep 0.$RANDOM
    while 
        ocf_pidfile_status $lockfile
    do
        ocf_log info "Sleeping until $lockfile is released..."
        sleep 0.$RANDOM
    done
    echo $$ > $lockfile
}


ocf_release_lock_on_exit() {
    lockfile=$1
    trap "rm -f $lockfile" EXIT
}

__ocf_set_defaults "$@"
++ __ocf_set_defaults showdbstat
++ __OCF_ACTION=showdbstat
++ unset LANG
++ LC_ALL=C
++ export LC_ALL
++ '[' -z '' ']'
++ : 0
++ '[' '!' -d /usr/lib/ocf ']'
++ '[' -z '' ']'
++ : oracle
++ '[' -z '' ']'
++ : We are being invoked as an init script.
++ : Fill in some things with reasonable values.
++ : default
++ return 0

#######################################################################

usage() {
  methods=`oracle_methods`
  methods=`echo $methods | tr ' ' '|'`
  cat <<-!
}

meta_data() {
        cat <<END
}


#
# methods: What methods/operations do we support?
#
oracle_methods() {
  cat <<-!
}


#       Gather up information about our oracle instance

ora_info() {
        ORACLE_SID=$1
        ORACLE_HOME=$2
        ORACLE_OWNER=$3

        # get ORACLE_HOME from /etc/oratab if not set
        [ x = "x$ORACLE_HOME" ] &&
                ORACLE_HOME=`awk -F: "/^$ORACLE_SID:/"'{print $2}' /etc/oratab`

        # there a better way to find out ORACLE_OWNER?
        [ x = "x$ORACLE_OWNER" ] &&
                ORACLE_OWNER=`ls -ld $ORACLE_HOME/. 2>/dev/null | awk 
'NR==1{print $3}'`

        sqlplus=$ORACLE_HOME/bin/sqlplus
        lsnrctl=$ORACLE_HOME/bin/lsnrctl
        tnsping=$ORACLE_HOME/bin/tnsping
}

testoraenv() {
        #       Let's make sure a few important things are set...
        [ x != "x$ORACLE_HOME" -a x != "x$ORACLE_OWNER" ] ||
                return 1
        #       and some important things are there
        [ -x "$sqlplus" -a -x "$lsnrctl" -a -x "$tnsping" ] ||
                return 1
        return 0
}

setoraenv() {
        LD_LIBRARY_PATH=$ORACLE_HOME/lib
        LIBPATH=$ORACLE_HOME/lib
        TNS_ADMIN=$ORACLE_HOME/network/admin
        PATH=$ORACLE_HOME/bin:$ORACLE_HOME/dbs:$PATH
        export ORACLE_SID ORACLE_HOME ORACLE_OWNER TNS_ADMIN
        export LD_LIBRARY_PATH LIBPATH
}

#
#       Run commands as the Oracle owner...
#
execsql() {
        if [ "$US" = "$ORACLE_OWNER" ]; then
                $sqlplus -S /nolog
        else
                su - $ORACLE_OWNER -c "$sqlplus -S /nolog"
        fi
}

#
#       Run commands in the oracle admin sqlplus...
#
dbasql() {
        local func
        (
        echo "connect / as sysdba"
        echo "set feedback off"
        echo "set heading off"
        echo "set pagesize 0"
        for func; do $func; done
        ) |
        execsql | grep -v '^Connected'
}

#
# various interesting sql
#
dbstat() {
        echo 'select status from v$instance;'
}
dbmount() {
        echo 'alter database mount;'
}
dbopen() {
        echo 'alter database open;'
}
dbstop_immediate() {
        echo 'shutdown immediate'
}
dbstop_checkpoint_abort() {
        echo 'alter system checkpoint;'
        echo 'shutdown abort'
}
dbstop() {
        case "${shutdown_method}" in
        "immediate")
                dbstop_immediate
        ;;
        "checkpoint/abort")
                dbstop_checkpoint_abort
        ;;
        esac
}
dbstart() {
        echo 'startup'
}
dbstart_mount() {
        echo 'startup mount'
}
dbendbackup() {
        echo 'alter database end backup;'
}
db_backup_mode() {
        echo "select 'COUNT'||count(*) from v\$backup where status='ACTIVE';"
}
is_clear_backupmode_set(){
        [ x"${clear_backupmode}" = x"true" ]
}
is_instance_in_backup_mode() {
        local count
        count="`dbasql db_backup_mode | sed 's/COUNT//'`"
        [ x"$count" != x"0" ]
}
clear_backup_mode() {
        local output
        output="`dbasql dbendbackup`"
        ocf_log info "Oracle instance $ORACLE_SID alter database end backup: 
$output"
}
getdumpdest() {
        #echo 'select value from v$parameter where name = \'user_dump_dest\';'
        echo "select value from v\$parameter where name = 'user_dump_dest';"
}
getipc() {
        echo "oradebug setmypid"
        echo "oradebug ipc"
}
#
# print the output of dbstat (for debugging)
#
showdbstat() {
        echo "Full output:"
        dbstat | execsql
        echo "Stripped output:"
        echo "<`dbasql dbstat`>"
}

#
# IPC stuff: not overly complex, but quite involved :-/
#

# Part 1: Oracle
dumpinstipc() {
        local dumpdest=`dbasql getdumpdest`
        [ "x$dumpdest" != x -a -d "$dumpdest" ] || return 1
        local -i fcount=`ls -rt $dumpdest | wc -l`
        dbasql getipc >/dev/null 2>&1
        local lastf=`ls -rt $dumpdest | grep -v '^\.*$' | tail -1`
        local -i fcount2=`ls -rt $dumpdest | wc -l`
        [ $((fcount+1)) -eq $fcount2 ] || return 1  # more than one file created
        echo $dumpdest/$lastf
}
parseipc() {
        local inf=$1
        test -f "$1" || return 1
        awk '
                $3 == "Shmid" {n=1;next}
                n {
                        if( $3~/^[0-9]+$/ ) print $3;
                        n=0
                }
        ' $inf |
        sort -u | sed 's/^/m:/'
        awk '
                /Semaphore List/ {insems=1;next}
                insems {
                        for( i=1; i<=NF; i++ )
                                if( $i~/^[0-9]+$/ ) print $i;
                }
                /system semaphore information/ {exit}
        ' $inf |
        sort -u | sed 's/^/s:/'
}

# Part 2: OS (ipcs,ipcrm)
filteroraipc() {  # this portable?
        grep -w $ORACLE_OWNER | awk '{print $2}'
}
ipcdesc() {
        local what=$1
        case $what in
        m) echo "shared memory segment";;
        s) echo "semaphore";;
        q) echo "message queue";;
        esac
}
rmipc() {
        local what=$1 id=$2
        ipcs -$what | filteroraipc | grep -w $id >/dev/null 2>&1 ||
                return
        ocf_log info "Removing `ipcdesc $what` $id."
        ipcrm -$what $id
}
ipcrm_orauser() {
        local what id
        for what in m s q; do
                for id in `ipcs -$what | filteroraipc`; do
                        rmipc $what $id
                done
        done
}
ipcrm_instance() {
        local ipcobj
        for ipcobj; do
                rmipc `echo $ipcobj | sed 's/:/ /'`
        done
}

#
# oracle_status: is the Oracle instance running?
#
# quick check to see if the instance is up
is_oracle_up() {
        ps -ef | grep -wiqs "[^ ]*[_]pmon_${ORACLE_SID}"
}
# instance in OPEN state?
instance_live() {
        [ "`dbasql dbstat`" = OPEN ]
}

ora_cleanup() {
        #rm -fr /tmp/.oracle #???
        rm -f `ls $ORACLE_HOME/dbs/lk* | grep -i $ORACLE_SID`
        #return

        case $IPCRM in
        none)
                ;;
        instance)
                ipcrm_instance $*
                ;;
        orauser)
                ipcrm_orauser $*
                ;;
        *)
        ocf_log warn "bad usage: ipcrm set to $IPCRM"
                ;;
        esac
}

#
# oracle_start: Start the Oracle instance
#
# NOTE: We handle instance in the MOUNTED and STARTED states
# efficiently
# We *do not* handle instance in the restricted or read-only
# mode, i.e. it appears as running, but its availability is
# "not for general use"
#

oracle_start() {
        local status output
        if is_oracle_up; then
                status="`dbasql dbstat`"
                case "$status" in
                "OPEN")
                        : nothing to be done, we can leave right now
                        ocf_log info "Oracle instance $ORACLE_SID already 
running"
                        return $OCF_SUCCESS
                ;;
                "STARTED")
                        output=`dbasql dbmount`
                ;;
                "MOUNTED")
                        : we proceed if mounted
                ;;
                *) # status unknown
                        output=`dbasql dbstop dbstart_mount`
                ;;
                esac
        else
                output="`dbasql dbstart_mount`"
                # try to cleanup in case of
                # ORA-01081: cannot start already-running ORACLE - shut it down 
first
                if echo "$output" | grep ORA-01081 >/dev/null 2>&1; then
                        ora_cleanup
                        output=`dbasql dbstart_mount`
                fi
        fi

        # oracle instance should be mounted.
        status="`dbasql dbstat`"
        case "$status" in
        "MOUNTED")
                ;;
        *)
                : error!!
                ocf_log error "Oracle $ORACLE_SID can not mount."
                return $OCF_ERR_GENERIC
                ;;
        esac

        # It is examined whether mode is "online backup mode",
        # and if it is true, makes clear the mode.
        # Afterwards, DB is opened.
        if is_clear_backupmode_set && is_instance_in_backup_mode; then
                clear_backup_mode
        fi
        output=`dbasql dbopen`

        if is_oracle_up && instance_live; then
                : cool, we are up and running
                ocf_log info "Oracle instance $ORACLE_SID started: $output"
                return $OCF_SUCCESS
        else
                ocf_log err "Oracle instance $ORACLE_SID not started: $output"
                return $OCF_ERR_GENERIC
        fi
}

#
# oracle_stop: Stop the Oracle instance
#
oracle_stop() {
        local status output ipc=""
        if is_oracle_up; then
                [ "$IPCRM" = "instance" ] && ipc=$(parseipc `dumpinstipc`)
                output=`dbasql dbstop`
        else
                ocf_log info "Oracle instance $ORACLE_SID already stopped"
                return $OCF_SUCCESS
        fi
        ora_kill  # kill any processes left
        if is_oracle_up; then
                ocf_log err "Oracle instance $ORACLE_SID not stopped: $output"
                return $OCF_ERR_GENERIC
        else
                ocf_log info "Oracle instance $ORACLE_SID stopped: $output"
                sleep 1  # give em a chance to cleanup
                ocf_log info "Cleaning up for $ORACLE_SID"
                ora_cleanup "$ipc"
                return $OCF_SUCCESS
        fi
}
# kill the database processes (if any left)
# give them 30 secs to exit cleanly (6 times 5)
killprocs() {
        local sig=$1
        shift 1
        kill -$sig $* >/dev/null 2>&1
}
ora_kill() {
        killprocs TERM `eval $procs | awk '{print $1}'`
        for i in 1 2 3 4 5; do
                killprocs 0 `eval $procs | awk '{print $1}'` ||
                        return
                sleep 5
        done
        killprocs KILL `eval $procs | awk '{print $1}'`
}

#
# oracle_monitor: Can the Oracle instance do anything useful?
#
oracle_monitor() {
        if is_oracle_up && instance_live
        then
                #ocf_log info "Oracle instance $ORACLE_SID is alive"
                return $OCF_SUCCESS
        else
                ocf_log info "Oracle instance $ORACLE_SID is down"
                return $OCF_NOT_RUNNING
        fi
}

#
#       'main' starts here...
#

if [ $# -ne 1 ]
then
  usage
  exit $OCF_ERR_ARGS
fi
+ '[' 1 -ne 1 ']'

# These operations don't require OCF instance parameters to be set
case "$1" in
  meta-data)    meta_data
                exit $OCF_SUCCESS;;

  usage)        usage
                exit $OCF_SUCCESS;;

  methods)      oracle_methods
                exit $?;;

  *);;
esac
+ case "$1" in

clear_backupmode=${OCF_RESKEY_clear_backupmode:-"false"}
+ clear_backupmode=false
shutdown_method=${OCF_RESKEY_shutdown_method:-"checkpoint/abort"}
+ shutdown_method=checkpoint/abort

case "${shutdown_method}" in
"immediate") ;;
"checkpoint/abort") ;;
*) ocf_log error "unsupported shutdown_method, please read meta-data"
esac
+ case "${shutdown_method}" in

if [ x = "x$OCF_RESKEY_sid" ]
then
  ocf_log err "Please set OCF_RESKEY_sid to the Oracle SID !"
  exit $OCF_ERR_ARGS
fi
+ '[' x = xdssd ']'

ora_info "$OCF_RESKEY_sid" "$OCF_RESKEY_home" "$OCF_RESKEY_user"
+ ora_info dssd /appl01/app/oracle/product/10.2 oracle
+ ORACLE_SID=dssd
+ ORACLE_HOME=/appl01/app/oracle/product/10.2
+ ORACLE_OWNER=oracle
+ '[' x = x/appl01/app/oracle/product/10.2 ']'
+ '[' x = xoracle ']'
+ sqlplus=/appl01/app/oracle/product/10.2/bin/sqlplus
+ lsnrctl=/appl01/app/oracle/product/10.2/bin/lsnrctl
+ tnsping=/appl01/app/oracle/product/10.2/bin/tnsping

LSB_STATUS_STOPPED=3
+ LSB_STATUS_STOPPED=3
if ! testoraenv; then
        ocf_log info "Oracle environment for SID $ORACLE_SID does not exist"
        case "$1" in
                stop) exit $OCF_SUCCESS;;
                monitor) exit $OCF_NOT_RUNNING;;
                status) exit $LSB_STATUS_STOPPED;;
                *)
                        ocf_log err "Oracle environment for SID $ORACLE_SID 
broken"
                        exit $OCF_ERR_ARGS
                ;;
        esac
fi
+ testoraenv
+ '[' x '!=' x/appl01/app/oracle/product/10.2 -a x '!=' xoracle ']'
+ '[' -x /appl01/app/oracle/product/10.2/bin/sqlplus -a -x 
/appl01/app/oracle/product/10.2/bin/lsnrctl -a -x 
/appl01/app/oracle/product/10.2/bin/tnsping ']'
+ return 0

setoraenv # important: set the environment for the SID
+ setoraenv
+ LD_LIBRARY_PATH=/appl01/app/oracle/product/10.2/lib
+ LIBPATH=/appl01/app/oracle/product/10.2/lib
+ TNS_ADMIN=/appl01/app/oracle/product/10.2/network/admin
+ 
PATH=/appl01/app/oracle/product/10.2/bin:/appl01/app/oracle/product/10.2/dbs:/usr/lib64/heartbeat:/usr/sbin:/usr/share/heartbeat:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/ucb
+ export ORACLE_SID ORACLE_HOME ORACLE_OWNER TNS_ADMIN
+ export LD_LIBRARY_PATH LIBPATH
procs="ps -e -o pid,args | grep -i \"[o]ra.*$ORACLE_SID\""
+ procs='ps -e -o pid,args | grep -i "[o]ra.*dssd"'

US=`id -u -n`
id -u -n
++ id -u -n
+ US=root
if [ $US != root -a $US != $ORACLE_OWNER ]
then
  ocf_log err "$0 must be run as root or $ORACLE_OWNER"
  exit $OCF_ERR_PERM
fi
+ '[' root '!=' root -a root '!=' oracle ']'

if [ x = "x$OCF_RESKEY_ipcrm" ]
then
        IPCRM="instance"
else
        IPCRM="$OCF_RESKEY_ipcrm"
fi
+ '[' x = x ']'
+ IPCRM=instance

# What kind of method was invoked?
case "$1" in

  start)        oracle_start
                exit $?;;

  stop)         oracle_stop
                exit $?;;

  status)       if is_oracle_up
                then
                  echo Oracle instance $ORACLE_SID is running
                  exit $OCF_SUCCESS
                else
                  echo Oracle instance $ORACLE_SID is stopped
                  exit $OCF_NOT_RUNNING
                fi
                ;;

  dumpinstipc)
          is_oracle_up && parseipc `dumpinstipc`
                exit $?;;

  showdbstat)
          showdbstat
                exit $?;;

  cleanup)
                if [ "$IPCRM" = "instance" ]; then
                        ora_cleanup $(parseipc `dumpinstipc`)
                else
                        ora_cleanup
                fi
                exit $?;;

  monitor)      oracle_monitor
                exit $?;;

  validate-all) # OCF_RESKEY_sid was already checked by testoraenv(),
                # just exit successfully here.
                exit $OCF_SUCCESS;;

  *)            oracle_methods
                exit $OCF_ERR_UNIMPLEMENTED;;
esac
+ case "$1" in
+ showdbstat
+ echo 'Full output:'
Full output:
+ dbstat
+ echo 'select status from v$instance;'
+ execsql
+ '[' root = oracle ']'
+ su - oracle -c '/appl01/app/oracle/product/10.2/bin/sqlplus -S /nolog'
ENV MSG: Server Express environment enabled
SP2-0640: Not connected
+ echo 'Stripped output:'
Stripped output:
dbasql dbstat
++ dbasql dbstat
++ local func
++ echo 'connect / as sysdba'
++ echo 'set feedback off'
++ echo 'set heading off'
++ echo 'set pagesize 0'
++ for func in '"$@"'
++ dbstat
++ echo 'select status from v$instance;'
++ execsql
++ '[' root = oracle ']'
++ su - oracle -c '/appl01/app/oracle/product/10.2/bin/sqlplus -S /nolog'
++ grep -v '^Connected'
+ echo '<ENV MSG: Server Express environment enabled
OPEN>'
<ENV MSG: Server Express environment enabled
OPEN>
+ exit 0
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to