import sys
import os
import pymqi
import time
import re
if len(sys.argv) != 5:
print sys.argv[0] + ' ' + 'queue_manager' + ' ' + 'channel' + ' ' + 'host' + ' ' + 'port'
else:
queue_manager = sys.argv[1]
channel = sys.argv[2]
host = sys.argv[3]
port = sys.argv[4]
conn_info = "%s(%s)" % (host, port)
prefix = "*"
queue_type = pymqi.CMQC.MQQT_LOCAL
args = {pymqi.CMQC.MQCA_Q_NAME: prefix,
pymqi.CMQC.MQIA_Q_TYPE: queue_type}
print '-----------------------------------------'
print args
print '-----------------------------------------'
qmgr = pymqi.connect(queue_manager, channel, conn_info)
pcf = pymqi.PCFExecute(qmgr)
response = pcf.MQCMD_INQUIRE_Q(args)
for queue_info in response:
queue_name = queue_info[pymqi.CMQC.MQCA_Q_NAME]
if (re.match('^SYSTEM',queue_name) or re.match('^AMQ',queue_name) or re.match('^MQ',queue_name)):
pass
else:
q = pymqi.Queue(qmgr, queue_name)
print(queue_name.strip() +':'+'Queue depth:', q.inquire(pymqi.CMQC.MQIA_CURRENT_Q_DEPTH))
q.close()
qmgr.disconnect()
[mqm@node01 sbin]$ python disdepth.py YWJZZF_CZCB_SEND CHANNEL1 127.0.0.1 5015
-----------------------------------------
{2016: '*', 20: 1}
-----------------------------------------
('CZ_RSP:Queue depth:', 1)
('DEADQ:Queue depth:', 3)
('ERRMSG:Queue depth:', 0)
('SEND000:Queue depth:', 8)