使用python获得activemq信息(通过http://server:8161/
2014-09-07 16:58
666 查看
# encoding=utf-8 import urllib2 import cookielib # from BeautifulSoup import BeautifulSoup from bs4 import BeautifulSoup import re queue_url = "http://192.168.16.218:8161/admin/queues.jsp" def MQBrowser(url): login_page = queue_url try: cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'), ('Authorization', 'Basic YWRtaW46YWRtaW4=')] opener.open(url) op = opener.open(login_page) data = op.read() return data except Exception, e: print str(e) def get_queue_size_by_name(queue_name): content = MQBrowser(queue_url) soup = BeautifulSoup(''.join(content)) queue_list = soup.findAll('tbody')[1].findAll('tr') for i in queue_list: queue_info = i.findAll('td') if queue_name == queue_info[0].text.strip(): num_pending = queue_info[1].text.strip() return num_pending return -1 def get_queue_size(): content = MQBrowser(queue_url) soup = BeautifulSoup(''.join(content)) queue_list = soup.findAll('tbody')[1].findAll('tr') queue_dic = {} for i in queue_list: queue_info = i.findAll('td') queue_name = queue_info[0].text.strip() num_pending = queue_info[1].text.strip() num_consumer = queue_info[2].text.strip() num_enqueued = queue_info[3].text.strip() num_dequeued = queue_info[4].text.strip() queue_dic[queue_name] = [num_pending, num_consumer, num_enqueued, num_dequeued] return queue_dic def get_queue_detail(queue_name): content = MQBrowser("http://127.0.0.1:8161/admin/browse.jsp?JMSDestination=%s" % queue_name) soup = BeautifulSoup(''.join(content)) if __name__ == "__main__": import sys if len(sys.argv) == 2: queue_name = sys.argv[1] else: queue_name = "None" # print get_queue_size_by_name(queue_name)
相关文章推荐
- arcgis通过 Python 使用工具 获得结果信息
- 使用WinInet从HTTP服务器下载信息--Downloading from an HTTP Server using WinInet
- python client使用http post 到server端的代码
- python通过pil模块获得图片exif信息的方法
- python获得http头信息
- 百度语音识别REST API——通过使用Http网络请求方式获得语音识别功能
- [zz]通过win32扩展接口使用 Python获得系统进程列表的方法
- 使用ASIHTTPRequest获得天气信息
- iOS开发工具-如何使用网络封包分析工具Charles,通过配置proxy对http、https、tcp、udp 等协议的请求响应过程交互信息进行分析、判断、解决我们移动开发中的遇到的各种实际问题。
- 记录一下:使用 python -m SimpleHTTPServer 快速搭建http服务
- 使用ASIHTTPRequest获得天气信息
- IIS安全工具UrlScan介绍 ASP.NET 两种超强SQL 注入免费解决方案( 基于IIS,使用免费工具) 批改或隐藏IIS7.5的Server头信息 移除X-Powered-By,MVC,ASP.NET_SessionId 的 HTTP头或者cookie名称
- python通过exifread模块获得图片exif信息
- 使用Python创建简单的HTTP服务(基于SimpleHTTPServer) 和 FTP服务(基于pyftpdlib)
- 使用python在win下通过IE组件获得Ajax执行后网页源代码
- python client使用 http post 到server端
- python 在linux下通过top,和dh命令获得cpu,内存,以及硬盘信息
- 使用Perfmon和PAL工具查看Server性能--从性能监视器获得更多有用信息
- 使用python来操作hive(通过 pyhs2 和 HiveServer2)