Method: NETSNMP::Client#walk
- Defined in:
- lib/netsnmp/client.rb
#walk(oid:) ⇒ Enumerator
Perform a SNMP Walk (issues multiple subsequent GENEXT requests within the subtree rooted on an OID)
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/netsnmp/client.rb', line 81 def walk(oid:) walkoid = OID.build(oid) Enumerator.new do |y| code = walkoid first_response_code = nil catch(:walk) do loop do get_next(oid: code) do |response| response.varbinds.each do |varbind| code = varbind.oid if !OID.parent?(walkoid, code) || varbind.value.eql?(:endofmibview) || (code == first_response_code) throw(:walk) else y << [code, varbind.value] end first_response_code ||= code end end end end end end |