Class: SNMP4EM::NotificationManager
- Inherits:
-
Object
- Object
- SNMP4EM::NotificationManager
- Defined in:
- lib/snmp4em/notification_manager.rb
Overview
Provides access to receive SNMP traps (SNMPv1) and notifications (SNMPv2)
Instance Attribute Summary collapse
-
#community_ro ⇒ Object
readonly
Returns the value of attribute community_ro.
-
#community_rw ⇒ Object
readonly
Returns the value of attribute community_rw.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ NotificationManager
constructor
Creates a new object to communicate with SNMP agents.
-
#on_trap(&block) ⇒ Object
Register a callback that is upon reception of a trap/notification.
Constructor Details
#initialize(args = {}) ⇒ NotificationManager
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)
9 10 11 12 13 14 |
# File 'lib/snmp4em/notification_manager.rb', line 9 def initialize(args = {}) @host = args[:host] || "127.0.0.1" @port = args[:port] || 162 @socket = EM::open_datagram_socket(@host, @port, NotificationHandler) end |
Instance Attribute Details
#community_ro ⇒ Object (readonly)
Returns the value of attribute community_ro.
4 5 6 |
# File 'lib/snmp4em/notification_manager.rb', line 4 def community_ro @community_ro end |
#community_rw ⇒ Object (readonly)
Returns the value of attribute community_rw.
4 5 6 |
# File 'lib/snmp4em/notification_manager.rb', line 4 def community_rw @community_rw end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/snmp4em/notification_manager.rb', line 4 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
4 5 6 |
# File 'lib/snmp4em/notification_manager.rb', line 4 def port @port end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries.
4 5 6 |
# File 'lib/snmp4em/notification_manager.rb', line 4 def retries @retries end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/snmp4em/notification_manager.rb', line 4 def timeout @timeout end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
4 5 6 |
# File 'lib/snmp4em/notification_manager.rb', line 4 def version @version end |
Instance Method Details
#on_trap(&block) ⇒ Object
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.
19 20 21 |
# File 'lib/snmp4em/notification_manager.rb', line 19 def on_trap &block @socket.callbacks << block end |