# Queue Depth Script in MQ on unix



## aramudhan

Trying to write a shell script to check the queue depth on mq server and once its reaches a particular level (5000), mail should be triggered to our mailbox saying for this "queue" queue depth reached to this "value".

Script :

#!/usr/bin/ksh
#alert script
b=5000
set -A a `'echo "dis q(*) where(curdepth gt 5000)" | runmqsc QMGR_QM | grep CURDEPTH | cut -c13-16'`
set -A c `'echo "dis q(*) where(curdepth gt 5000)" | runmqsc QMGR_QM | grep QUEUE | cut -c10-80 | cut -d ")"
-f1`
for i in ${a[@]}
do
for j in ${c[@]}
do
if [ $i -ge $b ]
then
echo "$j queue depth is $i" | mail -s "Queue depth alert" [email protected]
fi
done
done

On the above script two array variables are declared to store values dynamically.Variable "a" stores queue depth in numbers.Varible "c" stores queue name in string.

I am not sure how to get the values of "$a" and its corresponding value of "$c" one by one and sending it to mailbox. If $a has 4 values and $c has 4 values, the current script throws 16 mails to mailbox with outputs of permutation and combinations of $a and $c which is not correct. Expected output is to get a single mail with 4 lines as listed below.

Q1 queue depth is 5025
Q2 queue depth is 5087
Q3 queue depth is 5523
Q4 queue depth is 5752

Please advise.

Thanks and Regards,

Aramudhan.


----------



## lotuseclat79

What is the actual name of the MQ server software that formats the queues in Unix? What Unix?

-- Tom


----------



## aramudhan

Hi Tom

Actual name of MQ server software is Websphere MQ and this runs on AIX.

Please let me know if you need any futher info.

Thanks and Regards,

Aramudhan.


----------



## lotuseclat79

Hi aramudhan,

Can you show the complete output of the 16 messages?

Thanks,

-- Tom


----------

