class SNMP4EM::SnmpGetNextRequest
The result of calling {SNMPCommonRequests#getnext}.
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_getnext_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_getnext_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_getnext_request.rb 18 def handle_response(response) # @private 19 super 20 21 if response.error_status == :noError 22 pending_oids.zip(response.varbind_list).each do |oid, response_vb| 23 value = format_value(response_vb) 24 25 if value.is_a? SNMP::ResponseError 26 oid[:response] = value 27 else 28 oid[:response] = [response_vb.name.to_s, format_value(response_vb)] 29 end 30 31 oid[:state] = :complete 32 end 33 34 else 35 error_oid = pending_oids[response.error_index - 1] 36 error_oid[:state] = :error 37 error_oid[:error] = SNMP::ResponseError.new(response.error_status) 38 end 39 40 if pending_oids.empty? 41 result = {} 42 43 @oids.each do |oid| 44 requested_oid = oid[:requested_string] 45 result[requested_oid] = oid[:error] || oid[:response] 46 end 47 48 succeed result 49 return 50 end 51 52 send_msg 53 end
Private Instance Methods
send_msg()
click to toggle source
Calls superclass method
# File lib/snmp4em/requests/snmp_getnext_request.rb 57 def send_msg 58 Manager.track_request(self) 59 60 query_oids = @oids.select{|oid| oid[:state] == :pending}.collect{|oid| oid[:requested_oid]} 61 62 vb_list = SNMP::VarBindList.new(query_oids) 63 request = SNMP::GetNextRequest.new(@snmp_id, vb_list) 64 message = SNMP::Message.new(@sender.version, @sender.community_ro, request) 65 66 super(message) 67 end