class SNMP4EM::NotificationHandler
Attributes
callbacks[RW]
Public Instance Methods
post_init()
click to toggle source
# File lib/snmp4em/notification_handler.rb 5 def post_init 6 @callbacks = [] 7 end
receive_data(data)
click to toggle source
# File lib/snmp4em/notification_handler.rb 9 def receive_data(data) 10 source_port, source_ip = Socket.unpack_sockaddr_in(get_peername) 11 12 begin 13 message = SNMP::Message.decode(data) 14 rescue Exception => err 15 return 16 end 17 18 trap = message.pdu 19 20 return unless trap.is_a?(SNMP::SNMPv1_Trap) || trap.is_a?(SNMP::SNMPv2_Trap) 21 22 trap.source_ip = source_ip 23 24 @callbacks.each { |callback| callback.yield(message.pdu) } 25 end