#NEWLINE# def report_table_metrics( self , instance , results ) : #NEWLINE# #INDENT# '\n        For each of the metrics specified as needing to be resolved with mib,\n        gather the tags requested in the instance conf for each row.\n\n        Submit the results to the aggregator.\n        ' #NEWLINE# tags = instance . get ( 'tags' , [ ] ) #NEWLINE# tags = ( tags + [ ( 'snmp_device:' + instance . get ( 'ip_address' ) ) ] ) #NEWLINE# for metric in instance . get ( 'metrics' , [ ] ) : #NEWLINE# #INDENT# if ( 'table' in metric ) : #NEWLINE# #INDENT# index_based_tags = [ ] #NEWLINE# column_based_tags = [ ] #NEWLINE# for metric_tag in metric . get ( 'metric_tags' , [ ] ) : #NEWLINE# #INDENT# tag_key = metric_tag [ 'tag' ] #NEWLINE# if ( 'index' in tag_key ) : #NEWLINE# #INDENT# index_based_tags . append ( ( tag_key , metric_tag . get ( 'index' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'column' in metric_tag ) : #NEWLINE# #INDENT# column_based_tags . append ( ( tag_key , metric_tag . get ( 'column' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . log . warning ( 'No indication on what value to use for this tag' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for value_to_collect in metric . get ( 'symbols' , [ ] ) : #NEWLINE# #INDENT# for ( index , val ) in results [ value_to_collect ] . items ( ) : #NEWLINE# #INDENT# metric_tags = ( tags + self . get_index_tags ( index , results , index_based_tags , column_based_tags ) ) #NEWLINE# self . submit_metric ( value_to_collect , val , metric_tags ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'symbol' in metric ) : #NEWLINE# #INDENT# name = metric [ 'symbol' ] #NEWLINE# result = results [ name ] . items ( ) #NEWLINE# if ( len ( result ) > 1 ) : #NEWLINE# #INDENT# self . log . warning ( 'Several rows corresponding while the metric is supposed to be a scalar' ) #NEWLINE# continue #NEWLINE# #UNINDENT# val = result [ 0 ] [ 1 ] #NEWLINE# self . submit_metric ( name , val , tags ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'OID' in metric ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( ( 'Unsupported metric in config file: %s' % metric ) )