lib/arborist/monitor/snmp/cpu.rb
changeset 19 77084121952b
parent 14 d5cb8bd33170
child 26 54f2f57cc0b0
equal deleted inserted replaced
18:cedffd6652d3 19:77084121952b
    22 	}
    22 	}
    23 
    23 
    24 	# When walking load OIDS, the iterator count matches
    24 	# When walking load OIDS, the iterator count matches
    25 	# these labels.
    25 	# these labels.
    26 	#
    26 	#
    27 	LOADKEYS = {
    27 	LOADKEYS = %i[ load1 load5 load15 ]
    28 		1 => :load1,
       
    29 		2 => :load5,
       
    30 		3 => :load15
       
    31 	}
       
    32 
    28 
    33 
    29 
    34 	# Global defaults for instances of this monitor
    30 	# Global defaults for instances of this monitor
    35 	#
    31 	#
    36 	configurability( 'arborist.snmp.cpu' ) do
    32 	configurability( 'arborist.snmp.cpu' ) do
    94 		# an extended load event.  Use the 5 minute average to avoid
    90 		# an extended load event.  Use the 5 minute average to avoid
    95 		# state changes on transient spikes.
    91 		# state changes on transient spikes.
    96 		#
    92 		#
    97 		else
    93 		else
    98 			snmp.walk( oid: OIDS[:load] ).each_with_index do |(_, value), idx|
    94 			snmp.walk( oid: OIDS[:load] ).each_with_index do |(_, value), idx|
    99 				next unless LOADKEYS[ idx + 1 ]
    95 				next unless LOADKEYS[ idx ]
   100 				info[ :load ][ LOADKEYS[idx + 1] ] = value.to_f
    96 				info[ :load ][ LOADKEYS[idx] ] = value.to_f
   101 			end
    97 			end
   102 
    98 
   103 			percentage = (( ( info[:load][ :load5 ] / cpus.size) - 1 ) * 100 ).round( 1 )
    99 			percentage = (( ( info[:load][ :load5 ] / cpus.size) - 1 ) * 100 ).round( 1 )
   104 
   100 
   105 			if percentage < 0
   101 			if percentage < 0