#! /bin/bash ########################################################################### # # # DO NOT CHANGE THIS FILE - IT WILL BE OVERWRITTEN !!! # # # ########################################################################### # NAME # qc_broker_std.LIB - Library of broker functions for QAD Cloud # # DESCRIPTION # The following functions will be provided by qc_broker_std.LIB # adminserverUp - Returns 0 if AdminServer is running, otherwise 1 # getBroker - Will set qcAPS an array of appserver and qcWTB # an array of WebSpeed brokers # # SYNTAX # . lib/qc_shell_std.LIB # . lib/qc_broker_std.LIB # # AUTHOR # Written by John Brink (j6b@qad.com) # # REVISION HISTORY # 1.0 03/01/2016 j6b - Initial version # ------------------------------------------------------------------------- # vim:ts=4 ##------------------## ## Define Functions ## ##------------------## function adminserverUp() { ########################################################### # Usage # adminserverUp # # Description # Verify if AdminServer is up and running # Give AdminServer maximum 2 minutes to be up and running # # Exitcode # 0 - AdminServer is up and running # 1 - AdminServer is NOT running # # Author # Written by John Brink (j6b@qad.com) # # Revision history # 1.0 03/02/2016 - j6b - Initial version # --------------------------------------------------------- local _endtime=$(( $(date +%s) + 120 )) while : do if (( $(date +%s) > _endtime )) then #logMsg ERR "AdminServer is not running for ${qcENV}" return 1 fi ${DLC}/bin/proadsv -port ${qcPORT} -q|grep "(8545)" > /dev/null 2>&1 && return 0 sleep 10 done } getBroker() { ########################################################### # Usage # getBroker - get all appserver and WebSpeed brokers # # Description # getBroker will return an array qcAPS with all appserver # and qcWTB with all WebSpeed brokers # # Result # The following parameters will be set: # qcAPS - Array of appserver brokers # qcWTB - Array of WebSpeed brokers # # Author # Written by John Brink (j6b@qad.com) # # Revision history # 1.0 02/19/2016 - j6b - Initial version # --------------------------------------------------------- local _ubrkr=${DLC}/properties/ubroker.properties qcAPS=( ) qcWTB=( ) if [[ ! -f ${_ubrkr} ]] then logMsg ERR "${_ubrkr} could not be found" exit 1 fi # GET APPSERVER NAMES FROM U_broker.PROPERTIES AND START for _broker in $(grep "\[UBroker\.." ${_ubrkr} | grep '.AS\.' | grep -v broker1 | grep -v icfrepos | sed "s/\]//g" | sed "s/\[UBroker\.AS\.//g") do qcAPS+=( "${_broker}" ) # Add broker to array done # GET WEBSPEED NAMES FROM U_broker.PROPERTIES AND START for _broker in $(grep "\[UBroker\.." ${_ubrkr} | grep '.WS\.' | grep -v broker1 | grep -v icfrepos | grep -v wsdynamics1 | sed "s/\]//g" | sed "s/\[UBroker\.WS\.//g") do qcWTB+=( "${_broker}" ) # Add WebSpeed to array done export qcAPS qcWTB } function brokerRunning() { ########################################################### # Usage # brokerRunning # # Description # Verify if supplied broker is up and running # Give broker maximum 2 minutes to be up and running # # Exitcode # 0 - Specified broker is up and running # 1 - Specified broker is NOT running # 2 - Specified broker could not be found # 3 - Specified broker is running but no AVAILABLE agents # # Author # Written by John Brink (j6b@qad.com) # # Revision history # 1.0 03/10/2016 - j6b - Initial version # --------------------------------------------------------- local _endtime=$(( $(date +%s) + 120 )) local _broker=${1} while : do if (( $(date +%s) > _endtime )) then #logMsg ERR "Broker ${_broker} is not running for ${qcENV}" return 1 fi if ${DLC}/bin/asbman -i ${_broker} -port ${qcPORT} -q|grep "(8281)" > /dev/null 2>&1 then # (8281) - Unable to find return 2 elif ${DLC}/bin/asbman -i ${_broker} -port ${qcPORT} -q|grep "Broker Status"|grep "ACTIVE" > /dev/null 2>&1 then if ${DLC}/bin/asbman -i ${_broker} -port ${qcPORT} -q|sed -n '/^PID/,$p'|grep "AVAILABLE" > /dev/null 2>&1 then return 0 else return 3 fi fi sleep 10 done }