class SNMP::SNMPv2_Trap
The PDU class for traps in SNMPv2c. Methods are provided for retrieving the values of the mandatory varbinds: the system uptime and the OID of the trap. The complete varbind list is available through the usual varbind_list method. The first two varbinds in this list will always be the uptime and trap OID varbinds.
Attributes
source_ip[RW]
Returns the source IP address for the trap, usually derived from the source IP address of the packet that delivered the trap.
Public Instance Methods
encode()
click to toggle source
# File lib/snmp/pdu.rb, line 246 def encode encode_pdu(SNMPv2_Trap_PDU_TAG) end
sys_up_time()
click to toggle source
Returns the value of the mandatory sysUpTime varbind for this trap.
Throws InvalidTrapVarbind if the sysUpTime varbind is not present.
# File lib/snmp/pdu.rb, line 261 def sys_up_time varbind = @varbind_list[0] if varbind && (varbind.name == SYS_UP_TIME_OID) return varbind.value else raise InvalidTrapVarbind, "Expected sysUpTime.0, found " + varbind.to_s end end
trap_oid()
click to toggle source
Returns the value of the mandatory snmpTrapOID varbind for this trap.
Throws InvalidTrapVarbind if the snmpTrapOID varbind is not present.
# File lib/snmp/pdu.rb, line 275 def trap_oid varbind = @varbind_list[1] if varbind && (varbind.name == SNMP_TRAP_OID_OID) return varbind.value else raise InvalidTrapVarbind, "Expected snmpTrapOID.0, found " + varbind.to_s end end