#NEWLINE# def collect( self ) : #NEWLINE# #INDENT# matches = [ ] #NEWLINE# for ( root , dirnames , filenames ) in os . walk ( self . memory_path ) : #NEWLINE# #INDENT# if ( not self . should_skip ( root ) ) : #NEWLINE# #INDENT# for filename in filenames : #NEWLINE# #INDENT# if ( filename == 'memory.stat' ) : #NEWLINE# #INDENT# parent = root . replace ( self . memory_path , '' ) . replace ( '/' , '.' ) #NEWLINE# if ( parent == '' ) : #NEWLINE# #INDENT# parent = 'system' #NEWLINE# #UNINDENT# matches . append ( ( parent , os . path . join ( root , filename ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# results = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for match in matches : #NEWLINE# #INDENT# results [ match [ 0 ] ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# stat_file = open ( match [ 1 ] ) #NEWLINE# elements = [ line . split ( ) for line in stat_file ] #NEWLINE# stat_file . close ( ) #NEWLINE# for el in elements : #NEWLINE# #INDENT# ( name , value ) = el #NEWLINE# if ( name not in _KEY_MAPPING ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# for unit in self . config [ 'byte_unit' ] : #NEWLINE# #INDENT# value = diamond . convertor . binary . convert ( value = value , oldUnit = 'B' , newUnit = unit ) #NEWLINE# results [ match [ 0 ] ] [ name ] = root #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for ( parent , cpuacct ) in results . iteritems ( ) : #NEWLINE# #INDENT# for ( key , value ) in cpuacct . iteritems ( ) : #NEWLINE# #INDENT# metric_name = '.' . join ( [ parent , key ] ) #NEWLINE# self . publish ( metric_name , value , metric_type = 'GAUGE' ) #NEWLINE# #UNINDENT# #UNINDENT# return True