Remove the unnecessary Hash.
authorMahlon E. Smith <mahlon@martini.nu>
Mon, 23 Jul 2018 09:42:02 -0700
changeset 19 77084121952b
parent 18 cedffd6652d3
child 20 00a38d493f2c
Remove the unnecessary Hash.
lib/arborist/monitor/snmp/cpu.rb
--- a/lib/arborist/monitor/snmp/cpu.rb	Wed Jun 13 08:55:14 2018 -0700
+++ b/lib/arborist/monitor/snmp/cpu.rb	Mon Jul 23 09:42:02 2018 -0700
@@ -24,11 +24,7 @@
 	# When walking load OIDS, the iterator count matches
 	# these labels.
 	#
-	LOADKEYS = {
-		1 => :load1,
-		2 => :load5,
-		3 => :load15
-	}
+	LOADKEYS = %i[ load1 load5 load15 ]
 
 
 	# Global defaults for instances of this monitor
@@ -96,8 +92,8 @@
 		#
 		else
 			snmp.walk( oid: OIDS[:load] ).each_with_index do |(_, value), idx|
-				next unless LOADKEYS[ idx + 1 ]
-				info[ :load ][ LOADKEYS[idx + 1] ] = value.to_f
+				next unless LOADKEYS[ idx ]
+				info[ :load ][ LOADKEYS[idx] ] = value.to_f
 			end
 
 			percentage = (( ( info[:load][ :load5 ] / cpus.size) - 1 ) * 100 ).round( 1 )