Class: SnmpDumper::Walker
- Inherits:
-
Object
- Object
- SnmpDumper::Walker
- Defined in:
- lib/walker.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Walker
constructor
A new instance of Walker.
- #walk(dumper) ⇒ Object
Constructor Details
#initialize(options) ⇒ Walker
Returns a new instance of Walker.
5 6 7 |
# File 'lib/walker.rb', line 5 def initialize() @options = end |
Instance Method Details
#walk(dumper) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/walker.rb', line 9 def walk(dumper) snmpconfig = { :Host => @options.host, :Port => @options.port, :Version => @options.version} snmpconfig.merge!({:Timeout => @options.timeout }) if @options.timeout snmpconfig.merge!({:Retries => @options.retries }) if @options.retries if @options.version == :SNMPv3 then snmpconfig.merge! Hash.new() else snmpconfig.merge! :Community => @options.community end STDERR.puts snmpconfig if $DEBUG manager = SNMP::Manager.new(snmpconfig) model = @options.model || manager.get_value('sysDescr.0') dumper.model = model dumper.category = @options.category (1..@options.walks).each do |i| STDERR.puts "Walk #{i}/#{@options.walks}: start" if $DEBUG @options.oids.each do |oid| begin manager.walk(oid) do |var_bind| dumper.add_snmp_var({:name => var_bind.name, :value => var_bind.value}) end rescue SNMP::RequestTimeout => e raise e if dumper.snmp_vars.empty? end end STDERR.puts "Walk #{i}/#{@options.walks}: end" if $DEBUG if i != @options.walks then STDERR.puts "Sleep for #{@options.interval} seconds" if $DEBUG sleep @options.interval end end manager.close end |