#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def get( self ) : #NEWLINE# #INDENT# stats = ( yield self . client . stats ( ) ) #NEWLINE# node_stats = ( yield self . client . node_stats ( ) ) #NEWLINE# status = { #NEWLINE# #INDENT# 'green' : 2 , #NEWLINE# 'yellow' : 1 , #NEWLINE# 'red' : 0 , #NEWLINE# #UNINDENT# } [ stats [ 'status' ] ] #NEWLINE# nodes = stats [ 'nodes' ] [ 'count' ] [ 'total' ] #NEWLINE# index_count = stats [ 'indices' ] [ 'count' ] #NEWLINE# shards = stats [ 'indices' ] [ 'shards' ] [ 'total' ] #NEWLINE# shards_primary = stats [ 'indices' ] [ 'shards' ] [ 'primaries' ] #NEWLINE# docs = stats [ 'indices' ] [ 'docs' ] [ 'count' ] #NEWLINE# store = stats [ 'indices' ] [ 'store' ] [ 'size_in_bytes' ] #NEWLINE# events = [ self . createEvent ( 'ok' , 'Status' , status , prefix = 'cluster.status' ) , self . createEvent ( 'ok' , 'Nodes' , nodes , prefix = 'cluster.nodes' ) , self . createEvent ( 'ok' , 'Indices' , index_count , prefix = 'indices' ) , self . createEvent ( 'ok' , 'Shards' , shards , prefix = 'shards.total' ) , self . createEvent ( 'ok' , 'Primary shards' , shards_primary , prefix = 'shards.primary' ) , self . createEvent ( 'ok' , 'Documents' , shards_primary , prefix = 'documents.total' ) , self . createEvent ( 'ok' , 'Documents' , shards_primary , prefix = 'documents.rate' , aggregation = Counter64 ) , self . createEvent ( 'ok' , 'Store size' , store , prefix = 'documents.size' ) ] #NEWLINE# nodes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( k , v ) in node_stats [ 'nodes' ] . items ( ) : #NEWLINE# #INDENT# node_name = v [ 'host' ] #NEWLINE# if ( v . get ( 'attributes' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( 'client' , 'false' ) == 'true' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( node_name not in nodes ) : #NEWLINE# #INDENT# nodes [ node_name ] = { #NEWLINE# #INDENT# 'search' : v [ 'indices' ] [ 'search' ] [ 'query_total' ] , #NEWLINE# 'delete' : v [ 'indices' ] [ 'indexing' ] [ 'delete_total' ] , #NEWLINE# 'index' : v [ 'indices' ] [ 'indexing' ] [ 'index_total' ] , #NEWLINE# 'get' : v [ 'indices' ] [ 'get' ] [ 'total' ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# for ( node , ms ) in nodes . items ( ) : #NEWLINE# #INDENT# for ( mname , m ) in ms . items ( ) : #NEWLINE# #INDENT# events . append ( self . createEvent ( 'ok' , mname , m , prefix = ( 'nodes.%s.%s' % ( node , mname ) ) , aggregation = Counter64 ) ) #NEWLINE# #UNINDENT# #UNINDENT# defer . returnValue ( events )