Operating System - HP-UX
1748265 Members
4006 Online
108760 Solutions
New Discussion юеВ

Re: how to extract the number of queue on MQ

 
SOLVED
Go to solution
roberto salvatori_1
Occasional Advisor

how to extract the number of queue on MQ

hi all,
i have some problems to extract from MQ the number of queue from a single MQ channel.
here we are what i see from a runmqsc

*******************************************
root@sysint04:/usr/sysint/SOM# runmqsc
5724-B41 (C) Copyright IBM Corp. 1994, 2002. ALL RIGHTS RESERVED.
Starting MQSC for queue manager System.Integration.Manager.


DIS QUEUE(MQ01) CURDEPTH
1 : DIS QUEUE(MQ01) CURDEPTH
AMQ8409: Display Queue details.
QUEUE(MQ01) CURDEPTH(0)
*******************************************

what i want is to extract the number into CURDEPTH().
what shall i do? with awk i've extracted the last row ( QUEUE(MQ01) CURDEPTH(0)) but i don't know how to read every single character and find the number.
please, help me.
thanks in advice

roberto.sal
9 REPLIES 9
Muthukumar_5
Honored Contributor
Solution

Re: how to extract the number of queue on MQ

WE can do as,

runmqsc | awk '/^QUEUE\(MQ01\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }'

From your example input,
cat testfile
5724-B41 (C) Copyright IBM Corp. 1994, 2002. ALL RIGHTS RESERVED.
Starting MQSC for queue manager System.Integration.Manager.


DIS QUEUE(MQ01) CURDEPTH
1 : DIS QUEUE(MQ01) CURDEPTH
AMQ8409: Display Queue details.
QUEUE(MQ01) CURDEPTH(0)

# awk '/^QUEUE\(MQ01\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }' testfile
0

HTH.

Easy to suggest when don't know about the problem!
roberto salvatori_1
Occasional Advisor

Re: how to extract the number of queue on MQ

thanks a lot Muthukumar,
the script works fine with the example that i've posted into forum but i want to understand what you did.
can you do this?
tell if i'm in wrong:
you have found in all rows that begin with QUEUE(MQ01). but after?
and if i have this what can i do?

**************************************
5724-B41 (C) Copyright IBM Corp. 1994, 2002. ALL RIGHTS RESERVED.
Starting MQSC for queue manager System.Integration.Manager.


1 : DIS QUEUE(MQ01) CURDEPTH
AMQ8409: Display Queue details.
QUEUE(MQ01) CURDEPTH(0)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
*************************************
if you can see QUEUE(MQ01) begin with some spaces and it doesn't work with your script. why?
thanks and best regards

roberto.sal
roberto salvatori_1
Occasional Advisor

Re: how to extract the number of queue on MQ

this forum trim the spaces, eheheh.
i link the file that contains the output of runmqsc.
be patint with me, :)
roberto salvatori_1
Occasional Advisor

Re: how to extract the number of queue on MQ

i've found by myself the solution.
the string to search must contains the blank spaces. so the command will be:

awk '/^ QUEUE\(MQ01\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }' test.log

simple, no?
thanks a lot.
roberto.sal
roberto salvatori_1
Occasional Advisor

Re: how to extract the number of queue on MQ

this is not the end. now i've found another problem: when i try to run the script, the system gives me an error

*************************
root@sysint04:/usr/sysint/SOM# ./check_mqqueue.sh
./check_mqqueue.sh: test: argument expected
*************************

the script is this:

*************************
#!/bin/sh
MQQUEUE="MQ01 MQ17 MQ18 MQ25 MQ44 MQ52 MQ54"
LOGDIR=/var/tmp/si
LOGFILE=$LOGDIR/check_mqqueue.log
MQNAME=$LOGDIR/mqqueuename.log

#*** MAIN ***
rm -rf $LOGFILE $MQNAME
flag=0
for i in $MQQUEUE
do
runmqsc << EOF >> $LOGFILE
DIS QUEUE($i) CURDEPTH
EOF
#NUMQUEUE=`awk '/^ QUEUE\($i\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }' $LOGFILE`
#echo $NUMQUEUE
if [ `awk '/^ QUEUE\($i\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }' $LOGFILE` -gt 50 ]; the
n
echo $i >> $MQNAME
flag=1
fi
done
...
*************************

i suppose that the error can be found on this part of the script but i'm not so sure:

awk '/^ QUEUE\($i\)/

i think that to reference the variable ($i) this is not the right method. if yes, what can i do?
waiting for you
thanks
roberto salvatori_1
Occasional Advisor

Re: how to extract the number of queue on MQ

i've found by myself the solution. here we are the script:

**********************************
flag=0
for i in $MQQUEUE
do
RUNMQ $i
PT=`awk '/^ QUEUE\('"$i"'\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }' $LOGFILE`
if [ "$PT" -gt 10 ]; then
sleep 10
RUNMQ $i
ST=`awk '/^ QUEUE\('"$i"'\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }' $LOGFILE`
if [ "$ST" -gt 10 ]; then
echo $i >> $MQNAME
flag=1
fi
fi
done
if [ $flag -eq 1 ]; then
...
*******************************

so, you can see that i've used this method ('"$i"') to say to awk to use the external variable. i hope that can be helpfull to someone else.
best regards to everyone.

roberto.sal
Muthukumar_5
Honored Contributor

Re: how to extract the number of queue on MQ

We can do your requirement to get queue size when,

QUEUE(MQ01) CURDEPTH(0) pattern is beginning with spaces as,

awk '/CURDEPTH\(/ { split($2,a,"("); split(a[2],b,")"); print b[1] }' testfile




awk '/^[ ]*QUEUE\(/ { split($2,a,"("); split(a[2],b,")"); print b[1] }' testfile

/^[ ]*QUEUE\(/ will search for 0 to n spaces at begin with QUEUE( there.

HTH.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: how to extract the number of queue on MQ

IS

PT=`awk '/^ QUEUE\('"$i"'\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }' $LOGFILE`
ST=`awk '/^ QUEUE\('"$i"'\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }' $LOGFILE`
working there?? with awk?

awk pattern is not working there.

Change that operation as,
PT=`grep "^[ ]*QUEUE($i)[ ]*CURDEPTH(" $LOGFILE | awk '/^ QUEUE\('"$i"'\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }'`

and
ST=`grep "^[ ]*QUEUE($i)[ ]*CURDEPTH(" $LOGFILE | awk '/^ QUEUE\('"$i"'\)/ { split($2,a,"("); split( a[2],b,")"); print b[1] }'`

It will work now.

HTH.
Easy to suggest when don't know about the problem!
roberto salvatori_1
Occasional Advisor

Re: how to extract the number of queue on MQ

yes, it works fine. but i will try your new code.
thanks a lot