#! /Usr/bin/Python
Import JSON
Import pycurl
Import cstringio
Def work_url (IP ):
Buf = cstringio. stringio ()
C = pycurl. Curl ()
C. setopt (C. url, "http: // % s: 8983/SOLR/collection1/admin/mbeans? Stats = true & Wt = JSON & _ = 1409194287592 "% IP)
C. setopt (C. writefunction, Buf. Write)
C. Perform ()
A = Buf. getvalue ()
Buf. Close ()
Return
If _ name _ = '_ main __':
Dict = {}
For I in range (4, 10 ):
IP = '10. 13.144.22 '+ STR (I)
B = work_url (IP)
Data = JSON. Loads (B)
Print data
Dict [IP] = {}
Select_avgtimeperrequest = data ['solr-mbeans '] [3] ['/select'] ['stats'] ['avgtimeperrequest']
Select_avgrequestspersecond = data ['solr-mbeans '] [3] ['/select'] ['stats'] ['avgrequestspersecond']
Cache_document = data ['solr-mbeans '] [7] ['documentcache'] ['stats'] ['cumulative _ hitratio']
Dict [IP] ['select'] = {}
Dict [IP] ['select'] ['avgtimeperrequest'] = select_avgtimeperrequest
Dict [IP] ['select'] ['avgrequestspersecond'] = select_avgrequestspersecond
Dict [IP] ['select'] ['hitratio '] = cache_document
Print dict
This article is from the "batch CT Batch Data Synchronization" blog, please be sure to keep this source http://4249964.blog.51cto.com/4239964/1562177
Solrcloud data monitoring