Module: SNMPUtils
- Defined in:
- lib/snmputils.rb
Overview
Class Method Summary collapse
-
.get(opts, oids) ⇒ Hash
SNMP get.
-
.walk(opts, oids) ⇒ List
SNMP walk.
Class Method Details
.get(opts, oids) ⇒ Hash
SNMP get. Return a Hash representation of the values at the input oids
102 103 104 105 106 |
# File 'lib/snmputils.rb', line 102 def self.get(opts, oids) return snmpget(opts,oids).inject({}) do |row, value| row.merge(oid_keyval(value)).merge(name_keyval(value)) end end |
.walk(opts, oids) ⇒ List
SNMP walk. Return a List representation of the values at the input oids
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/snmputils.rb', line 115 def self.walk(opts, oids) return snmpwalk(opts, oids).inject([]) do |table, row| rawoids = row.inject({}) do |row_n, value| row_n.merge(oid_keyval(value)).merge(name_keyval(value)) end suffix = rawoids.keys.suffix table << rawoids.inject({}) do |row_n, kvpair| key, value = kvpair row_n.merge(key.sub(/#{suffix}$/, '') => value) end end end |