Class: SNMP::SNMPv2_Trap
Overview
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.
Direct Known Subclasses
Constant Summary
Constants inherited from PDU
PDU::ERROR_STATUS_CODE, PDU::ERROR_STATUS_NAME
Instance Attribute Summary collapse
-
#source_ip ⇒ Object
Returns the source IP address for the trap, usually derived from the source IP address of the packet that delivered the trap.
Attributes inherited from PDU
#error_index, #request_id, #varbind_list
Instance Method Summary collapse
- #encode ⇒ Object
-
#sys_up_time ⇒ Object
Returns the value of the mandatory sysUpTime varbind for this trap.
-
#trap_oid ⇒ Object
Returns the value of the mandatory snmpTrapOID varbind for this trap.
Methods inherited from PDU
decode, #each_varbind, #encode_pdu, #error_status, #error_status=, #initialize
Constructor Details
This class inherits a constructor from SNMP::PDU
Instance Attribute Details
#source_ip ⇒ Object
Returns the source IP address for the trap, usually derived from the source IP address of the packet that delivered the trap.
254 255 256 |
# File 'lib/snmp/pdu.rb', line 254 def source_ip @source_ip end |
Instance Method Details
#encode ⇒ Object
246 247 248 |
# File 'lib/snmp/pdu.rb', line 246 def encode encode_pdu(SNMPv2_Trap_PDU_TAG) end |
#sys_up_time ⇒ Object
Returns the value of the mandatory sysUpTime varbind for this trap.
Throws InvalidTrapVarbind if the sysUpTime varbind is not present.
261 262 263 264 265 266 267 268 |
# 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 ⇒ Object
Returns the value of the mandatory snmpTrapOID varbind for this trap.
Throws InvalidTrapVarbind if the snmpTrapOID varbind is not present.
275 276 277 278 279 280 281 282 |
# 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 |