#!/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/diag/cld_debug.sh 1.10 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 1990,2007 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)67 1.10 src/43haes/usr/sbin/cluster/diag/cld_debug.sh, hacmp.diags, 61haes_r714 3/2/07 13:42:40 # # COMPONENT_NAME: DIAG # # FUNCTIONS: intr_handler # usage1 # usage3 # usage4 ############################################################################### # # Name: cld_debug # # Description: Uses System Resource Controller to turn on/off # debugging/clruncmd. # Optionally saves output to file. # Returns: # 0 - Success # 1 - Failure # 2 - Wrong number of args # # Arguments: -l Level ( of debugging ) # -R filename ( for saving output ) # Process/Type of debugging to perform # # Environment: PATH # ############################################################################### intr_handler() { echo "Exiting." } ############################################################################### # # Set trap statement to catch hangup, interrupt, and quit signals # ############################################################################### trap intr_handler 1 2 3 PROGNAME="$0" STATUS=0 ############################################################################### # # Name: usage # # This routine displays the usage message and exits # # Arguments: none # Usage: usage # Returns: 1 - exit with error # Environment: # ############################################################################### usage1() { dspmsg scripts.cat 450 "Usage: $PROGNAME clstrmgr [-l level] [-R file]\n" $PROGNAME dspmsg scripts.cat 570 "Where: -l level is the level of debugging performed (0 - 9, where 0 turns debugging off)\n" dspmsg scripts.cat 571 " -R file is the file to which output is saved\n" dspmsg scripts.cat 572 "\nAllows real-time debugging of the Cluster Manager (clstrmgr) daemon.\n" exit 1 } usage3() { dspmsg scripts.cat 452 "usage: $PROGNAME -t clruncmd\n" $PROGNAME exit 1 } usage4() { dspmsg scripts.cat 575 "Invalid arguments\n" exit 1 } # # Main Starts Here # [ "$VERBOSE_LOGGING" = "high" ] && set -x PROGNAME=$(basename ${0}) PATH="$($(dirname ${0})/../utilities/cl_get_path all)" HA_DIR="$(cl_get_path)" # Get command line options set -- `getopt "t:h:l:R:" $*` if [ $? -ne 0 ] then usage4 fi # Parse command line. while [ $1 != -- ] do case $1 in -t) TYPE="$2" shift ; shift ;; -h) HOSTNAME="$2" shift ; shift ;; -l) LEVEL="$2" shift ; shift ;; -R) FILE="$2" shift ; shift ;; *) usage4 ;; esac done shift # lose the -- if [ "$TYPE" = "" ] then usage3 fi # Set defaults LOCALHOST=`hostname` HOSTNAME=${HOSTNAME:-"$LOCALHOST"} # default to localhost LEVEL=${LEVEL:-0} # default to 0 FILE=${FILE:-"/var/hacmp/log/cld_debug.out"} # default log file case $TYPE in "clstrmgr") if [ "$#" -gt "4" ] then usage1 fi if [ $LEVEL -gt 9 ] then dspmsg scripts.cat 454 "Setting to maximum debug level (9).\n" LEVEL=9 fi if [ $LEVEL -lt 1 ] then dspmsg scripts.cat 455 "Setting to minimum debug level (0).\n" dspmsg scripts.cat 456 "This turns debugging OFF.\n" dspmsg scripts.cat 458 "Waiting for clstrmgr to respond to SRC request...\n" cl_src_cmd -debug_off if [ $? -ne 0 ] then dspmsg scripts.cat 459 "$PROGNAME: SRC command failed.\n" $PROGNAME exit 1 fi exit $STATUS fi # Find pathname of clstrmgr.debug file from HACMPlogs ODM STANZA=`odmget -q"name = clstrmgr.debug" HACMPlogs` if [ "$STANZA" != "" ] then DESTDIR=`echo $STANZA | cut -d'"' -f8` CLSTRMGR_DEBUG="$DESTDIR/clstrmgr.debug" else dspmsg scripts.cat 463 "The cluster log entry for %s could not be found in the HACMPlogs ODM.\n" "clstrmgr.debug" dspmsg scripts.cat 464 "Defaulting to log directory %s for log file %s.\n" "/var/hacmp/log" "clstrmgr.debug" CLSTRMGR_DEBUG="/var/hacmp/log/clstrmgr.debug" fi if [ ! -f $CLSTRMGR_DEBUG ] then touch $CLSTRMGR_DEBUG fi dspmsg scripts.cat 458 "Waiting for clstrmgr to respond to SRC request...\n" cl_src_cmd -debug_on $LEVEL if [ $? -ne 0 ] then dspmsg scripts.cat 459 "$PROGNAME: SRC command failed.\n" $PROGNAME exit 1 fi tail -f $CLSTRMGR_DEBUG dspmsg scripts.cat 458 "Waiting for clstrmgr to respond to SRC request...\n" cl_src_cmd -debug_off RC=$? cp $CLSTRMGR_DEBUG $FILE if [ "$RC" -ne 0 ] then dspmsg scripts.cat 459 "$PROGNAME: SRC command failed.\n" $PROGNAME exit 1 else dspmsg scripts.cat 461 "SRC command succeeded.\n" exit 0 fi ;; "clruncmd") if [ "$#" -gt "4" ] then usage3 fi dspmsg scripts.cat 458 "Waiting for clstrmgr to respond to SRC request...\n" if [ "$LOCALHOST" = "$HOSTNAME" ] then cl_src_cmd -r else cl_rsh $HOSTNAME /usr/${HA_DIR}/sbin/cluster/diag/cl_src_cmd -r fi if [ $? -ne 0 ] then dspmsg scripts.cat 459 "$PROGNAME: SRC command failed.\n" $PROGNAME exit 1 else dspmsg scripts.cat 461 "SRC command succeeded.\n" fi ;; *) usage4 ;; esac exit $STATUS