Python Script monitors jmx page metrics
#!/user/bin/pythonImportUrllib2ImportJSONPrint '============================================='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 ']Printhjson['Beans'][0]['name']Printhjson['Beans'][0]['Modelertype']Printhjson['Beans'][0]['memnonheapusedm']Printhjson['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']PrintHEAPUSEDHTML3= 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']PrintBlocktotal
Python Queries HDFs jmx information