bin/metrics-snmp-if.rb in sensu-plugins-snmp-2.0.0 vs bin/metrics-snmp-if.rb in sensu-plugins-snmp-2.1.0

- old
+ new

@@ -121,10 +121,16 @@ long: '--low-capacity', boolean: true, default: false, description: 'Use low capacity counters' + option :timeout, + short: '-t TIMEOUT', + long: '--timeout TIMEOUT', + default: 5, + description: 'Request timeout' + def run # rubocop:disable Metrics/AbcSize if_table_HC_columns = %w( ifHCInOctets ifHCOutOctets ifHCInUcastPkts ifHCOutUcastPkts ifHCInMulticastPkts ifHCOutMulticastPkts @@ -141,10 +147,16 @@ ifInErrors ifOutErrors ifInDiscards ifOutDiscards ifSpeed ) if_table_columns = if_table_common_columns + (config[:low_capacity] ? if_table_LC_columns : if_table_HC_columns) - SNMP::Manager.open(host: config[:host].to_s, port: config[:port].to_i, community: config[:community].to_s, version: config[:version]) do |manager| + SNMP::Manager.open( + host: config[:host].to_s, + port: config[:port].to_i, + community: config[:community].to_s, + version: config[:version], + timeout: config[:timeout] + ) do |manager| manager.walk(if_table_columns) do |row_array| # turn row (an array) into a hash for eaiser access to the columns row = Hash[*if_table_columns.zip(row_array).flatten] puts row.inspect if config[:verbose] if_name = config[:include_name] ? "#{row['ifIndex'].value}__#{graphite_safe_name(row['ifName'].value.to_s)}" : row['ifIndex'].value.to_s