Class: Net::SNMP::TrapHandler

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Debug
Defined in:
lib/net/snmp/trap_handler/trap_handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Debug

#debug, #error, #fatal, #info, #print_packet, #time, #warn

Constructor Details

#initialize(&block) ⇒ TrapHandler

Returns a new instance of TrapHandler.



13
14
15
16
17
# File 'lib/net/snmp/trap_handler/trap_handler.rb', line 13

def initialize(&block)
  @listener = Net::SNMP::Listener.new
  @listener.on_message(&method(:process_trap))
  self.instance_eval(&block)
end

Instance Attribute Details

#listenerObject

Returns the value of attribute listener.



6
7
8
# File 'lib/net/snmp/trap_handler/trap_handler.rb', line 6

def listener
  @listener
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/net/snmp/trap_handler/trap_handler.rb', line 6

def message
  @message
end

#pduObject

Returns the value of attribute pdu.



6
7
8
# File 'lib/net/snmp/trap_handler/trap_handler.rb', line 6

def pdu
  @pdu
end

#v1_handlerObject

Returns the value of attribute v1_handler.



6
7
8
# File 'lib/net/snmp/trap_handler/trap_handler.rb', line 6

def v1_handler
  @v1_handler
end

#v2_handlerObject

Returns the value of attribute v2_handler.



6
7
8
# File 'lib/net/snmp/trap_handler/trap_handler.rb', line 6

def v2_handler
  @v2_handler
end

Class Method Details

.listen(port = 162, interval = 2, max_packet_size = 65_000, &block) ⇒ Object



9
10
11
# File 'lib/net/snmp/trap_handler/trap_handler.rb', line 9

def self.listen(port = 162, interval = 2, max_packet_size = 65_000, &block)
  self.new
end