class SNMP4EM::SnmpBulkWalkRequest
The result of calling {SNMPv2cRequests#bulkwalk}.
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_bulkwalk_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_bulkwalk_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_bulkwalk_request.rb 22 def handle_response(response) # @private 23 super 24 25 if response.error_status == :noError 26 vb_list = response.vb_list 27 vb_index = 0 28 curr_pending_oids = pending_oids 29 30 while response_vb = vb_list.shift 31 oid = curr_pending_oids[vb_index % curr_pending_oids.count] 32 response_oid = response_vb.name 33 34 next unless oid[:state] == :pending 35 36 if SNMP::EndOfMibView == response_vb.value 37 oid[:state] = :complete 38 39 elsif ! response_oid.subtree_of?(oid[:requested_oid]) 40 oid[:state] = :complete 41 else 42 oid[:responses][response_oid.to_s] = format_value(response_vb) 43 oid[:next_oid] = response_oid 44 end 45 46 vb_index += 1 47 end 48 49 else 50 error_oid = pending_oids[response.error_index - 1] 51 error_oid[:state] = :error 52 error_oid[:error] = SNMP::ResponseError.new(response.error_status) 53 end 54 55 if pending_oids.empty? || (@max_results && @oids.collect{|oid| oid[:responses].count}.max >= @max_results) 56 result = {} 57 58 @oids.each do |oid| 59 requested_oid = oid[:requested_string] 60 result[requested_oid] = oid[:error] || oid[:responses] 61 end 62 63 succeed result 64 return 65 end 66 67 send_msg 68 end
on_init(args)
click to toggle source
# File lib/snmp4em/requests/snmp_bulkwalk_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_bulkwalk_request.rb 72 def send_msg 73 Manager.track_request(self) 74 75 vb_list = SNMP::VarBindList.new(pending_oids.collect{|oid| oid[:next_oid]}) 76 77 # Gracefully handle a new constructor introduced in SNMP 1.3.1 78 if Gem::Version.new(SNMP::VERSION) >= Gem::Version.new("1.3.1") 79 request = SNMP::GetBulkRequest.new(@snmp_id, vb_list, 0, 10) 80 else 81 request = SNMP::GetBulkRequest.new(@snmp_id, vb_list) 82 83 request.max_repetitions = 10 84 request.non_repeaters = 0 85 end 86 87 message = SNMP::Message.new(@sender.version, @sender.community_ro, request) 88 89 super(message) 90 end