class SNMP4EM::NotificationManager

Provides access to receive SNMP traps (SNMPv1) and notifications (SNMPv2)

Attributes

community_ro[R]
community_rw[R]
host[R]
port[R]
retries[R]
timeout[R]
version[R]

Public Class Methods

new(args = {}) click to toggle source

Creates a new object to communicate with SNMP agents. Optionally pass in the following parameters:

  • host - IP/hostname of local interface on which to listen (default: 127.0.0.1)

  • port - UDP port on which to listen (default: 162)

   # File lib/snmp4em/notification_manager.rb
 9 def initialize(args = {})
10   @host    = args[:host]      || "127.0.0.1"
11   @port    = args[:port]      || 162
12 
13   @socket = EM::open_datagram_socket(@host, @port, NotificationHandler)
14 end

Public Instance Methods

on_trap(&block) click to toggle source

Register a callback that is upon reception of a trap/notification. Multiple callbacks can be registered. Each will be passed the trap/notification object. It is important to determine whether it is a SNMP::SNMPv1_Trap or SNMP::SNMPv2_Trap, as each behaves slightly differently.

   # File lib/snmp4em/notification_manager.rb
19 def on_trap &block
20   @socket.callbacks << block
21 end