码迷,mamicode.com
首页 > 编程语言 > 详细

Python查看MQ队列深度

时间:2014-07-12 08:40:14      阅读:502      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   os   

分享一段代码,很简单但是也很实用。

 1 #!/usr/bin/python
 2 #-*- coding:gb18030 -*-
 3 ‘‘‘
 4   Usage: mq.py [Qmgr]
 5         *get the queues‘ curdepth which type is local,
 6          and sorted by curdepth desc.
 7   Auth : kongdl@eastcom-sw.com
 8 ‘‘‘
 9 
10 import re
11 import os
12 import sys
13 
14 if __name__==__main__:
15         if len(sys.argv)!=2:
16                 print Usage: %s [Qmgr] % sys.argv[0]
17                 sys.exit(1)
18         Qmgr=sys.argv[1]
19 
20         text=os.popen("echo ‘DIS QUEUE(*) CURDEPTH QTYPE(QLOCAL)‘|runmqsc %s" % Qmgr).read()
21         queues=re.findall(rQUEUE\(([^*]*?)\), text)
22         if not queues:
23                 print MQ: QueueManager [%s] not exist % Qmgr
24                 sys.exit(2)
25         depths=re.findall(rCURDEPTH\(([^*]*?)\), text)
26         qdlist=sorted(zip(queues, depths), cmp=lambda x, y: cmp(int(y[1]), int(x[1])))
27 
28         print % 40s, %s % (QueueName, CurrentDepth)
29         for qd in qdlist:
30                 print % 40s, %s % (qd[0], qd[1])

 

贴张图,看看效果:

bubuko.com,布布扣

Python查看MQ队列深度,布布扣,bubuko.com

Python查看MQ队列深度

标签:des   style   blog   http   color   os   

原文地址:http://www.cnblogs.com/lichmama/p/3835255.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!