#!/usr/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2017,2019,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r720 src/43haes/usr/sbin/cluster/sa/wmq/sbin/cl_wmq_stop.sh 1.3 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2011 # 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 # @(#) 7d4c34b 43haes/usr/sbin/cluster/sa/wmq/sbin/cl_wmq_stop.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM ############################################################################### # # NAME: cl_wmq_stop # # PURPOSE: # The script ends the QM by using two phases, initially trying # an immediate end with a time-out and escalating to a # forced stop of remaining processes. # # FLAGS: # u:MQM user name # m:Queue manager name # # ARGS: # MQM user name # Queue manager name # # RETURN: # 0 on success # 1 on failure # ############################################################################# function stop_mqm { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x # First stop all associated MQ listeners typeset LSNRS=$(clodmget -n -q "name = "RESTART_METHOD"" -f value HACMPmonitor | grep -w "$QM -l" | awk '{print $NF}') for LSNR in $LSNRS; do $WMQ_HA_SBIN/cl_wmq_stoplsnr -u $MQU -m $QM -l $LSNR # Handling return code here is not required and proper log messages are logged. # Instead, proceed for stopping other listeners and queue manager done # Now proceed for stopping the mq server KLIB_SA_logmsg INFO 2 4 wmq_sa.cat "Stopping the WebSphere MQ \ server with Queue Manager %1\$s and user as %2\$s" "$QM" "$MQU" TIMEOUT=60 # waiting for a minute before stopping killing the Queue manager for severity in immediate brutal do # End the queue manager in the background to avoid # it blocking indefinitely. Run the TIMEOUT timer # at the same time to interrupt the attempt, and try a # more forceful version. If the brutal version fails, # nothing more can be done here. #Attempting ${severity} end of queue manager '${QM}'" case $severity in immediate) # Minimum severity of endmqm is immediate which severs # connections. # HA cluster should not be delayed by clients /usr/bin/su $MQU -c "/usr/mqm/bin/endmqm -i $QM &" ;; brutal) # This is a forced means of stopping queue manager processes. srchstr="( |-m)$QM *.*\$" for process in amqzmuc0 amqzxma0 amqfcxba amqfqpub amqpcsea \ amqzlaa0 amqzlsa0 runmqchi runmqlsr amqcrsta amqrrmfa \ amqrmppa amqzfuma amqzdmaa amqzmuf0 amqzmur0 amqzmgr0 do ps -ef | tr "\t" " " | grep $process | grep -v grep | \ egrep "$srchstr" | awk '{print $2}'| \ /usr/bin/su $MQU -c "xargs kill -9 > /dev/null 2>&1" done esac TIMED_OUT=yes SECONDS=0 while (( $SECONDS < ${TIMEOUT} )) do TIMED_OUT=yes i=0 while (( $i < 5 )) do # Check for execution controller termination srchstr="( |-m)$QM *.*\$" cnt=$(ps -ef | tr "\t" " " | grep amqzxma0 | grep -v grep | \ egrep "$srchstr" | awk '{print $2}' | wc -l ) (( i++ )) sleep 1 if (( $cnt == 0 )) then TIMED_OUT=no break fi done if [[ ${TIMED_OUT} == "no" ]] then break fi # "Waiting for ${severity} end of queue manager '${QM}'" sleep 1 done # timeout loop if [[ ${TIMED_OUT} == "yes" ]] then continue # to next level of urgency else break # queue manager is ended, job is done fi done # next phase return 0 } ############ #MAIN ############ [[ $VERBOSE_LOGGING == "high" ]] && set -x . /usr/es/sbin/cluster/sa/wmq/sbin/cl_wmq_Globals typeset opt typeset MQU typeset QM while getopts u:m: opt do case $opt in u) # mqm user name. MQU=$OPTARG ;; m) # qm name. QM=$OPTARG ;; esac done [[ -z $MQU || -z $QM ]] && exit 1 stop_mqm