import sys
import os
import pymqi
import time
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 = "*"
args = {pymqi.CMQCFC.MQCACH_CHANNEL_NAME: prefix}
print '-----------------------------------------'
print args
print '-----------------------------------------'
qmgr = pymqi.connect(queue_manager, channel, conn_info)
pcf = pymqi.PCFExecute(qmgr)
response = pcf.MQCMD_INQUIRE_CHANNEL_STATUS(args)
code={0:'MQCHS_INACTIVE',1:'MQCHS_BINDING',2:'MQCHS_STARTING',3:'MQCHS_RUNNING',4:'MQCHS_STOPPING ',5:'MQCHS_RETRYING',6:'MQCHS_STOPPED',7:'MQCHS_REQUESTING',8:'MQCHS_PAUSED',13:'MQCHS_INITIALIZING'}
for channel_info in response:
channelname = channel_info[3501]
channelstatus = code[channel_info[1527]]
print channelname.strip()+'->'+channelstatus
qmgr.disconnect()