bin/check-snmp.rb in sensu-plugins-snmp-2.1.0 vs bin/check-snmp.rb in sensu-plugins-snmp-3.0.0

- old
+ new

@@ -1,6 +1,8 @@ #!/usr/bin/env ruby +# frozen_string_literal: false + # Check SNMP # === # # This is a simple SNMP check script for Sensu, We need to supply details like # Server, port, SNMP community, and Limits @@ -95,11 +97,11 @@ puts 'DEBUG OUTPUT:' response.each_varbind { |vb| puts vb.inspect } end rescue SNMP::RequestTimeout unknown "#{config[:host]} not responding" - rescue => e + rescue StandardError => e unknown "An unknown error occured: #{e.inspect}" end operators = { 'le' => :<=, 'ge' => :>= } symbol = operators[config[:comparison]] @@ -117,10 +119,10 @@ vb.value end critical 'Critical state detected' if snmp_value.to_s.to_i.send(symbol, config[:critical].to_s.to_i) # #YELLOW - warning 'Warning state detected' if snmp_value.to_s.to_i.send(symbol, config[:warning].to_s.to_i) && !snmp_value.to_s.to_i.send(symbol, config[:critical].to_s.to_i) # rubocop:disable LineLength + warning 'Warning state detected' if snmp_value.to_s.to_i.send(symbol, config[:warning].to_s.to_i) && !snmp_value.to_s.to_i.send(symbol, config[:critical].to_s.to_i) # rubocop:disable Layout/LineLength unless snmp_value.to_s.to_i.send(symbol, config[:warning].to_s.to_i) ok 'All is well!' end end end