Class: SNMPTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/arpdb/snmp_transport.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, community = 'public') ⇒ SNMPTransport

Returns a new instance of SNMPTransport.



7
8
9
10
# File 'lib/arpdb/snmp_transport.rb', line 7

def initialize(host, community = 'public')
  @host = host
  @manager = SNMP::Manager.new(host: host, community: community, mib_modules: [], retries: 1)
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/arpdb/snmp_transport.rb', line 5

def host
  @host
end

#managerObject

Returns the value of attribute manager.



5
6
7
# File 'lib/arpdb/snmp_transport.rb', line 5

def manager
  @manager
end

Instance Method Details

#get(oid) ⇒ Object



24
25
26
# File 'lib/arpdb/snmp_transport.rb', line 24

def get(oid)
  manager.get(oid).each_varbind { |vb| return decode_value(vb) }
end

#walk(oids) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/arpdb/snmp_transport.rb', line 12

def walk(oids)
  result = Array.new
  manager.walk(oids) do |snmp_row|
    row = Array.new
    snmp_row.each do |vb|
      row << decode_value(vb)
    end
    result << row
  end
  result
end