Class: Net::SNMP::V2TrapDsl

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

Direct Known Subclasses

V2InformDsl

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Debug

#print_packet, #time

Constructor Details

#initialize(message) ⇒ V2TrapDsl

Returns a new instance of V2TrapDsl.



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

def initialize(message)
  @message = message
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

Instance Method Details

#oidObject Also known as: trap_oid



15
16
17
18
19
20
21
22
# File 'lib/net/snmp/trap_handler/v2_trap_dsl.rb', line 15

def oid
  vb = varbinds.find{|vb| vb.oid.to_s == Constants::OID_SNMP_TRAP_OID}
  if vb
    vb.value
  else
    nil
  end
end

#pduObject



11
12
13
# File 'lib/net/snmp/trap_handler/v2_trap_dsl.rb', line 11

def pdu
  message.pdu
end

#uptimeObject



25
26
27
28
29
30
31
32
# File 'lib/net/snmp/trap_handler/v2_trap_dsl.rb', line 25

def uptime
  vb = varbinds.find{|vb| vb.oid.to_s == Constants::OID_SYS_UP_TIME_INSTANCE}
  if vb
    vb.value
  else
    nil
  end
end

#varbindsObject



34
35
36
# File 'lib/net/snmp/trap_handler/v2_trap_dsl.rb', line 34

def varbinds
  pdu.varbinds
end