From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Vimal Upreti Newsgroups: gmane.os.tru64.managers Subject: CAA Script Date: Sun, 19 May 2002 18:37:56 +0400 Sender: tru64-unix-managers-owner@ornl.gov Message-ID: <9CC0EAD054A9324E960A5868EDCB7E662B8BA6@EXSERVER01.ohi_net.com> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1021820435 2975 127.0.0.1 (19 May 2002 15:00:35 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 19 May 2002 15:00:35 +0000 (UTC) Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.20.101]) by main.gmane.org with smtp (Exim 3.33 #1 (Debian)) id 179SAk-0000lk-00 for ; Sun, 19 May 2002 17:00:34 +0200 Original-Received: (qmail 19772 invoked by uid 5); 19 May 2002 14:40:54 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 19764 invoked from network); 19 May 2002 14:40:54 -0000 Original-Received: from unknown (HELO emroute1.cind.ornl.gov) (134.167.3.119) by 0 with SMTP; 19 May 2002 14:40:54 -0000 Original-Received: from emroute1.cind.ornl.gov (localhost [127.0.0.1]) by emroute1.cind.ornl.gov (PMDF V6.1 #39060) with ESMTP id <0GWD00DS54S68N@emroute1.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Sun, 19 May 2002 10:40:54 -0400 (EDT) Original-Received: from [212.72.22.90] by emroute1.cind.ornl.gov (PMDF V6.1 #39060) with SMTP id <0GWD000554R84U@emroute1.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Sun, 19 May 2002 10:40:24 -0400 (EDT) Original-Received: from cluster1.ohi_net.com by [212.72.22.90] via smtpd (for emroute1.cind.ornl.gov [134.167.3.119]) with SMTP; Sun, 19 May 2002 14:42:32 +0000 (UT) Original-To: tru64-unix-managers@ornl.gov X-MIMEOLE: Produced By Microsoft Exchange V6.0.5762.3 Thread-Topic: CAA Script Thread-Index: AcH/QZhh143m72iiEdaFCQCgJMBeMw== content-class: urn:content-classes:message X-MS-Has-Attach: X-MS-TNEF-Correlator: Xref: main.gmane.org gmane.os.tru64.managers:250 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:250 Dear all, =20 I have installed Oracle 9i (without RAC) in two Node Cluster(Alphaserver = 8200) with TruCluster5.1A. Oracle 9i is installed in Cluster_usr#oracle partition. We have here 23 = Databases, 22 Databases has to run in One Node and 1 in other Node.=20 As per Sample Template and Best Practice on Compaq Web Site, I could = customize my CAA Script (attached below). Now with this Script I can START all 22 Databases automatically but the = script goes into a loop and doesn't come out, which in turn shows this = service on UNKNOWN host & doesn't show UP STATUS. While the STOP Script works OK. Can somebody identify the error in this script or suggest some = alternative: Thanks & regards. Vimal Upreti *************************************************************************= ********************** #!/usr/bin/ksh -p # oramamg.scr # # ***************************************************************** # * * # * Copyright (c) Digital Equipment Corporation, 1991, 1999 * # * * # * All Rights Reserved. Unpublished rights reserved under * # * the copyright laws of the United States. * # * * # * The software contained on this media is proprietary to * # * and embodies the confidential technology of Digital * # * Equipment Corporation. Possession, use, duplication or * # * dissemination of the software and media is authorized only * # * pursuant to a valid written license from Digital Equipment * # * Corporation. * # * * # * RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure * # * by the U.S. Government is subject to restrictions as set * # * forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, * # * or in FAR 52.227-19, as applicable. * # * * # * * # ***************************************************************** # # @(#)$RCSfile: template.scr,v $ $Revision: 1.1.8.2 $ (DEC) $Date: # 2000/04/14 17:42:58 $ # # # TruCluster V5 sample CAA script for ORACLE # # ################################################################### # # The following section contains variables that can be set to best # suit your application. # # Please review each variable and set as needed. # # Set CAA_SCRIPT_DEBUG when invoking the script from command line # for testing. This will cause all output events to go to the terminal, # rather than being sent to EVM. # ################################################################### # # Application name - set this variable to a name that describes this # (mandatory) application. Enclose the name in double quotes. # Examples: "apache", "netscape" SERVICE_NAME=3D"ORAMAMG" # Associated Processes - the application configured may consist of # (mandatory single or multiple processes. Specifying the names # of the processes here allows CAA to monitor that they # are running and allows CAA to completely clean up when # stopping the application. # Ex: "proc1 proc2" # # ORATAB=3D/etc/oratab9i PROBE_PROCS=3D"" export PROBE_PROCS cat $ORATAB | while read LINE do case $LINE in \#*) ;; #comment-line in oratab *) # Proceed only if third field is 'Y'. if [ "`echo $LINE | awk -F: '{print $3}' -`" =3D "Y" ] ; then ORACLE_SID=3D`echo $LINE | awk -F: '{print $1}' -` if [ "$ORACLE_SID" =3D '*' ] ; then ORACLE_SID=3D"" fi export ORACLE_SID PROBE_PROCS=3D" $PROBE_PROCS \ ora_pmon_${ORACLE_SID} \ ora_dbw0_${ORACLE_SID} \ ora_lgwr_${ORACLE_SID} \ ora_reco_${ORACLE_SID} \ ora_ckpt_${ORACLE_SID} \ ora_smon_${ORACLE_SID} \ " export PROBE_PROCS fi ;; esac export PROBE_PROCS done # Following 8 lines are commented ...by OHI #PROBE_PROCS=3D"\ #ora_pmon_${ORA_INST} \ #ora_dbw0_${ORA_INST} \ #ora_lgwr_${ORA_INST} \ #ora_ckpt_${ORA_INST} \ #ora_smon_${ORA_INST} \ #ora_reco_${ORA_INST}\ #" # # Application Startup Command - CAA will invoke this command when = starting # (mandatory) the application. Include the command to execute along # with any flags and arguments needed. Use this # variable along with START_APPCMD2 (see below) when # dealing with a simple application start procedure. # # If the start procedure is complicated and/or involves # many commands, you may find it easier to disregard # this variable and manually code the commands needed # in the "Start" section of this script (see below). # # Another alternative for a complicated start procedure # is to create a separate script containing those # commands and specifying that script in this variable. # # Ex: "/cludemo/avs/avsetup -s" # # NOTE: if not set, you must manually code the commands # to start the application in the "Start" section of # this script. START_APPCMD=3D"su - oracle9i -c = /oracle/app/oracle9i/product/o9i/bin/dbstartohi" # # Secondary Application Startup Command - used in conjunction with the # (optional) Application Startup Command just described above. Use # if desired to implement a two-step startup process for # your application, if needed. #START_APPCMD2=3D"su - oadb -c 'date'" # Application Stop Command - CAA will invoke this command when stopping # (optional) the application. Include the command to execute along # with any flags and arguments needed. Use this # variable along with STOP_APPCMD2 (see below) when # dealing with a simple application stop procedure. # # If the stop procedure is complicated and/or involves # many commands, you may find it easier to disregard # this variable and manually code the commands needed # in the "Stop" section of this script (see below). # Another alternative for a complicated stop procedure # is to create a separate script containing those # commands and specifying that script in this variable. # # Ex: "/cludemo/avs/avsetup -k" # # NOTE: if not set, you should manually code the commands # to stop the application in the "Stop" section of # this script. Otherwise, this script will not stop the # application in a graceful manner. STOP_APPCMD=3D"su - oracle9i -c = /oracle/app/oracle9i/product/o9i/bin/dbshutimohi" # Secondary Application Stop Command - used in conjunction with the # (optional) Application Stop Command just described above. Use # if desired to implement a two-step stop process for # your application, if needed. #STOP_APPCMD2=3D"su - oadb -c date" # Application Directory - If set, this script will change to this = directory # (optional) prior to executing the start process. This may allow # you to not have to specify full path names for # commands or files in this directory. # # Ex: "/var/opt/product1" export SERVICE_NAME START_APPCMD #export APPDIR PROBE_PROCS STOP_APPCMD export STOP_APPCMD ################################################################ # # The following section contains variables used by CAA. We recommend # leaving them defined as is. # ################################################################ DEBUG_PRIORITY=3D100 INFO_PRIORITY=3D200 ERROR_PRIORITY=3D500 SCRIPT=3D$0 ACTION=3D$1 # Action (start, stop or check) EVMPOST=3D"/usr/bin/evmpost" # EVM command to post events DEBUG=3D0 if [ "$CAA_SCRIPT_DEBUG" !=3D "" ]; then DEBUG=3D1 EVMPOST=3D"/usr/bin/evmpost -r | /usr/bin/evmshow -d" fi export EVMPOST ACTION SCRIPT ################################################################## # # The following section contains procedures that are available to # be used from the start, stop, and check portions of this script. # ################################################################## # # postevent - Posts EVM event with specified parameters # # Argument: $1 - priority (optional) # $2 - message (optional) # # postevent () { typeset pri=3D$1 typeset msg=3D${2:-failed} typeset evt=3D'event { name sys.unix.clu.caa.action_script ' if [ ! -z "$pri" ]; then evt=3D"$evt priority $pri " fi evt=3D"$evt var {name name value \\\"$SERVICE_NAME\\\" } " evt=3D"$evt var {name script value \\\"$SCRIPT\\\" } " evt=3D"$evt var {name action value \\\"$ACTION\\\" } " evt=3D"$evt var {name message value \\\"$msg\\\" }" evt=3D"$evt }" evt=3D"echo $evt | $EVMPOST" eval $evt } # # getpid - list PIDs of all processes with supplied name # # Modified /sbin/init.d/bin/getpid to list all matches # # Arguments: process name # getpid () { if [ -n "$1" ]; then GETMYPID=3D$1 shift /bin/ps -e -o pid,command $* | while read mypid command args do if [ "$command" =3D "$GETMYPID" ]; then echo "$mypid" fi done fi } # # checkdaemon - return the number of instances of a daemon # # Argument: process name # Return: number of instances of the named daemon currently running # checkdaemon () { R=3D`getpid $1 | wc -l` return $R } # # zapdaemon - kill a given process using brutal force (i.e. -9) # # Argument: list of processes to kill # Return: 1 - failed to kill some process # 0 - killed all processes # zapdaemon () { typeset ret=3D0 for i in ${1} do checkdaemon ${i} if [ $? -ne 0 ]; then kill `getpid ${i}` checkdaemon ${i} if [ $? -ne 0 ]; then kill -9 `getpid ${i}` checkdaemon ${i} if [ $? -ne 0 ]; then postevent $ERROR_PRIORITY "${i}: stuck - could not kill -KILL" ret=3D1 else postevent $ERROR_PRIORITY "${i}: killed with -KILL" fi else postevent "" "${i}: killed" fi fi done return $ret } # # probeapp - Probe process to see if in process list. # # This simple form of process probing searches the process list for an # entry corresponding to the specified process. If found, all is assumed # to be well. # # More accurate process probing may be available depending upon the = nature # of your application. For instance, you might invoke a test command = that # the process should respond to and check the returned results. You = should # consider adding this type of probing to this script, if possible. # # Argument: process name # # Return: 1 - process not running # 0 - process running # probeapp () { checkdaemon $1 if [ $? -ne 0 ]; then postevent $DEBUG_PRIORITY "$1 check OK" return 0 else postevent $DEBUG_PRIORITY "$1 check failed" return 1 fi } ######################################################################## # # Main section of Action Script - starts, stops, or checks an = application # # This script is invoked by CAA when managing the application associated # with this script. # # Argument: $1 - start | stop | check # # Returns: 0 - successful start, stop, or check # 1 - error # ######################################################################## # # Start section - start the process and report results # # If the Application Startup Commands (see description above) were used, # little, if any modifications are needed in this section. If not used, # you may replace most of the contents in this section with your own # start procedure code. # # For improved serviceability, preserve the commands below that log # messages or posts events. # case $1 in 'start') postevent $DEBUG_PRIORITY "trying to start" # /usr/sbin/cluamgr -a = alias=3Dmamit,rpri=3D10,selp=3D10,selw=3D1,join,virtual=3Df # if [ "$START_APPCMD" !=3D "" ]; then out=3D`$START_APPCMD` status=3D$? if [ $status -ne 0 ]; then postevent $ERROR_PRIORITY "start($status): $out" exit 1 fi fi /usr/sbin/cluamgr -a = alias=3Dmamit,rpri=3D10,selp=3D10,selw=3D1,join,virtual=3Df # if [ "$START_APPCMD2" !=3D "" ]; then # out=3D`$START_APPCMD2` # status=3D$? # if [ $status -ne 0 ]; then # postevent $ERROR_PRIORITY "start 2($status): $out" # exit 1 #fi #fi ;; # # Stop section - stop the process and report results # # If the Application Stop Commands or Associated Processes (see = descriptions # above) were used, little, if any modifications are needed in this = section. # If not used, you may replace most of the contents in this section with # your own stop procedure code. # # For improved serviceability, preserve the commands below that log # messages or posts events. # 'stop') postevent $DEBUG_PRIORITY "trying to stop" # # Not using $APPDIR OHI .... #cd $APPDIR if [ "$STOP_APPCMD" !=3D "" ]; then out=3D`$STOP_APPCMD` status=3D$? if [ $status -ne 0 ]; then postevent $ERROR_PRIORITY "stop($status): $out" exit 1 fi fi /usr/sbin/cluamgr -a = alias=3Dmamit,rpri=3D1,selp=3D1,selw=3D1,join,virtual=3Df # if [ $STOP_APPCMD2 !=3D "" ]; then # out=3D`$STOP_APPCMD2` # status=3D$? # if [ $status -ne 0 ]; then # postevent $ERROR_PRIORITY "stop 2($status): $out" # exit 1 #fi #fi # # Kill stubborn processes and applications that don't have a stop = command # for i in ${PROBE_PROCS}; do zapdaemon ${i} done ;; # # Check section - check the process and report results # # If you specified $PROBE_PROCS (see earlier description), very little, # if any, changes are needed to have simple process checking. # # Your application might allow you to implement more accurate process # checking. If so, you may choose to implement that code here. See the # description for the probeapp function earlier in this script. # 'check') for i in ${PROBE_PROCS}; do postevent $DEBUG_PRIORITY "trying to check $i" probeapp $i if [ $? -ne 0 ]; then postevent "" "check failed for $i" exit 1 fi done ;; *) postevent $ERROR_PRIORITY "usage: $0 {start|stop|check}" exit 1 ;; esac postevent "" success exit 0 =20