zoukankan      html  css  js  c++  java
  • python 获取队列深度

    [mqm@node01 mqm]$ cat disdepth.py 
    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 mqm]$ python disdepth.py  YWJZZF_CZCB_SEND CHANNEL1 192.168.137.2 5015
    -----------------------------------------
    {2016: '*', 20: 1}
    -----------------------------------------
    ('CZ_RSP:Queue  depth:', 1)
    ('DEADQ:Queue  depth:', 3)
    ('ERRMSG:Queue  depth:', 0)
    ('SEND000:Queue  depth:', 8)

  • 相关阅读:
    (五)Redis在项目中应用
    股票收益最大问题
    (四)redigo
    (三)go-sql-driver
    为什么TCP要3次握手?4次挥手?
    分支预测
    事务隔离级别说明
    剑指offer解题思路锦集11-20题
    C++中的二义性问题
    memcached Vs redis
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349595.html
Copyright © 2011-2022 走看看