Class | SNMP::TrapListener |
In: |
lib/snmp/manager.rb
|
Parent: | Object |
Listens to a socket and processes received traps and informs in a separate thread.
require 'snmp' m = SNMP::TrapListener.new(:Port => 1062, :Community => 'public') do |manager| manager.on_trap_default { |trap| p trap } end m.join
DefaultConfig | = | { :Host => 'localhost', :Port => 162, :Community => 'public', :ServerTransport => UDPServerTransport, :MaxReceiveBytes => 8000} |
NULL_HANDLER | = | Proc.new {} |
Start a trap handler thread. If a block is provided then the block is executed before trap handling begins. This block is typically used to define the trap handler blocks.
The trap handler blocks execute in the context of the trap handler thread.
The most specific trap handler is executed when a trap arrives. Only one handler is executed. The handlers are checked in the following order:
Define a trap handler block for a specific trap ObjectId. This handler only applies to SNMPv2 traps. Note that symbolic OIDs are not supported by this method (like in the SNMP.Manager class).
Define the default trap handler. The default trap handler block is executed only if no other block is applicable. This handler should expect to receive both SNMPv1_Trap and SNMPv2_Trap objects.
Define a trap handler block for all SNMPv1 traps. The trap yielded to the block will always be an SNMPv1_Trap.
Define a trap handler block for all SNMPv2c traps. The trap yielded to the block will always be an SNMPv2_Trap. Note that InformRequest is a subclass of SNMPv2_Trap, so inform PDUs are also received by this handler.