#NEWLINE# def collect_snmp( self , device , host , port , community ) : #NEWLINE# #INDENT# '\n        Collect stats from device\n        ' #NEWLINE# self . log . info ( ( 'Collecting ServerTech PDU statistics from: %s' % device ) ) #NEWLINE# timestamp = time . time ( ) #NEWLINE# inputFeeds = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( gaugeName , gaugeOid ) in self . PDU_SYSTEM_GAUGES . items ( ) : #NEWLINE# #INDENT# systemGauges = self . walk ( gaugeOid , host , port , community ) #NEWLINE# for ( o , gaugeValue ) in systemGauges . items ( ) : #NEWLINE# #INDENT# metricName = gaugeName #NEWLINE# metricValue = float ( gaugeValue ) #NEWLINE# metricPath = '.' . join ( [ 'devices' , device , 'system' , metricName ] ) #NEWLINE# metric = Metric ( metricPath , metricValue , timestamp , 2 ) #NEWLINE# self . publish_metric ( metric ) #NEWLINE# #UNINDENT# #UNINDENT# inputFeedNames = self . walk ( self . PDU_INFEED_NAMES , host , port , community ) #NEWLINE# for ( o , inputFeedName ) in inputFeedNames . items ( ) : #NEWLINE# #INDENT# inputFeed = '.' . join ( o . split ( '.' ) [ ( - 2 ) : ] ) #NEWLINE# inputFeeds [ inputFeed ] = inputFeedName #NEWLINE# #UNINDENT# for ( gaugeName , gaugeOid ) in self . PDU_INFEED_GAUGES . items ( ) : #NEWLINE# #INDENT# inputFeedGauges = self . walk ( gaugeOid , host , port , community ) #NEWLINE# for ( o , gaugeValue ) in inputFeedGauges . items ( ) : #NEWLINE# #INDENT# inputFeed = '.' . join ( o . split ( '.' ) [ ( - 2 ) : ] ) #NEWLINE# metricName = '.' . join ( [ re . sub ( '\\.|\\\\' , '_' , inputFeeds [ inputFeed ] ) , gaugeName ] ) #NEWLINE# if ( gaugeName == 'infeedVolts' ) : #NEWLINE# #INDENT# metricValue = ( float ( gaugeValue ) / 10.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( gaugeName == 'infeedAmps' ) : #NEWLINE# #INDENT# metricValue = ( float ( gaugeValue ) / 100.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# metricValue = float ( gaugeValue ) #NEWLINE# #UNINDENT# #UNINDENT# metricPath = '.' . join ( [ 'devices' , device , 'input' , metricName ] ) #NEWLINE# metric = Metric ( metricPath , metricValue , timestamp , 2 ) #NEWLINE# self . publish_metric ( metric )