bin/metrics-snmp.rb in sensu-plugins-snmp-1.1.0 vs bin/metrics-snmp.rb in sensu-plugins-snmp-2.0.0
- old
+ new
@@ -8,11 +8,11 @@
# gem: sensu-plugin
# gem: snmp
#
# USAGE:
#
-# check-snmp -h host -C community -O oid -p prefix -s suffix
+# check-snmp -h host -P port -C community -O oid -p prefix -s suffix
#
# LICENSE:
# Copyright (c) 2013 Double Negative Limited
# Based on check-snmp.rb by Deepak Mohan Das <deepakmdass88@gmail.com>
#
@@ -28,10 +28,15 @@
short: '-h host',
boolean: true,
default: '127.0.0.1',
required: true
+ option :port,
+ short: '-P port',
+ long: '--port PORT',
+ default: '161'
+
option :community,
short: '-C snmp community',
boolean: true,
default: 'public'
@@ -69,10 +74,10 @@
default: ''
def run
mibs = config[:mibs].split(',')
begin
- manager = SNMP::Manager.new(host: config[:host].to_s, community: config[:community].to_s, version: config[:snmp_version].to_sym)
+ manager = SNMP::Manager.new(host: config[:host].to_s, port: config[:port].to_i, community: config[:community].to_s, version: config[:snmp_version].to_sym)
if config[:mibdir] && !mibs.empty?
manager.load_modules(mibs, config[:mibdir])
end
response = manager.get([config[:objectid].to_s])
rescue SNMP::RequestTimeout