python查询hdfs jmx信息
Posted nhs3217
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python查询hdfs jmx信息相关的知识,希望对你有一定的参考价值。
python脚本监控jmx页面指标
#!/user/bin/python import urllib2 import json print ‘=============================================‘ html = urllib2.urlopen(r‘http://192.168.137.105:50070/jmx?qry=Hadoop:service=NameNode,name=JvmMetrics‘) hjson = json.loads(html.read()) #print hjson[‘beans‘] print hjson[‘beans‘][0][‘name‘] print hjson[‘beans‘][0][‘modelerType‘] print hjson[‘beans‘][0][‘MemNonHeapUsedM‘] print hjson[‘beans‘][0][‘MemHeapUsedM‘] print ‘=============================================‘ html2 = urllib2.urlopen(r‘http://192.168.137.105:50070/jmx?get=Hadoop:service=NameNode,name=JvmMetrics::MemHeapUsedM‘) hjson2 = json.loads(html2.read()) heapUsed = hjson2[‘beans‘][0][‘MemHeapUsedM‘] print heapUsed html3 = urllib2.urlopen(r‘http://192.168.137.105:50070/jmx?get=Hadoop:service=NameNode,name=FSNamesystem::BlocksTotal‘) hjson3 = json.loads(html3.read()) blockTotal = hjson3[‘beans‘][0][‘BlocksTotal‘] print blockTotal
以上是关于python查询hdfs jmx信息的主要内容,如果未能解决你的问题,请参考以下文章