class SNMP4EM::SnmpWalkRequest
The result of calling {SNMPCommonRequests#walk}.
Attributes
snmp_id[RW]
Public Instance Methods
callback(&block)
click to toggle source
Used to register a callback that is triggered when the query result is ready. The resulting object is passed as a parameter to the block.
Calls superclass method
# File lib/snmp4em/requests/snmp_walk_request.rb 9 def callback &block 10 super 11 end
errback(&block)
click to toggle source
Used to register a callback that is triggered when query fails to complete successfully.
Calls superclass method
# File lib/snmp4em/requests/snmp_walk_request.rb 14 def errback &block 15 super 16 end
handle_response(response)
click to toggle source
Calls superclass method
# File lib/snmp4em/requests/snmp_walk_request.rb 22 def handle_response(response) # @private 23 super 24 25 if response.error_status == :noError 26 pending_oids.zip(response.varbind_list).each do |oid, response_vb| 27 response_oid = response_vb.name 28 29 if SNMP::EndOfMibView == response_vb.value 30 # For SNMPv2, this indicates we've reached the end of the MIB 31 oid[:state] = :complete 32 elsif ! response_oid.subtree_of?(oid[:requested_oid]) 33 oid[:state] = :complete 34 else 35 oid[:responses][response_oid.to_s] = format_value(response_vb) 36 oid[:next_oid] = response_oid 37 end 38 end 39 40 elsif response.error_status == :noSuchName 41 # For SNMPv1, this indicates we've reached the end of the MIB 42 error_oid = pending_oids[response.error_index - 1] 43 error_oid[:state] = :complete 44 45 else 46 error_oid = pending_oids[response.error_index - 1] 47 error_oid[:state] = :error 48 error_oid[:error] = SNMP::ResponseError.new(response.error_status) 49 end 50 51 if pending_oids.empty? || (@max_results && @oids.collect{|oid| oid[:responses].count}.max >= @max_results) 52 result = {} 53 54 @oids.each do |oid| 55 requested_oid = oid[:requested_string] 56 result[requested_oid] = oid[:error] || oid[:responses] 57 end 58 59 succeed result 60 return 61 end 62 63 send_msg 64 end
on_init(args)
click to toggle source
# File lib/snmp4em/requests/snmp_walk_request.rb 18 def on_init args # @private 19 @oids.each{|oid| oid.merge!({:next_oid => oid[:requested_oid], :responses => {}})} 20 end
Private Instance Methods
send_msg()
click to toggle source
Calls superclass method
# File lib/snmp4em/requests/snmp_walk_request.rb 68 def send_msg 69 Manager.track_request(self) 70 71 vb_list = SNMP::VarBindList.new(pending_oids.collect{|oid| oid[:next_oid]}) 72 request = SNMP::GetNextRequest.new(@snmp_id, vb_list) 73 message = SNMP::Message.new(@sender.version, @sender.community_ro, request) 74 75 super(message) 76 end