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
Methods included from BER::Decode
#assert_no_remainder, #build_integer, #decode_integer, #decode_integer_value, #decode_ip_address, #decode_object_id, #decode_object_id_value, #decode_octet_string, #decode_sequence, #decode_timeticks, #decode_tlv, #decode_uinteger_value
Methods included from BER::Encode
#encode_exception, #encode_integer, #encode_length, #encode_null, #encode_object_id, #encode_octet_string, #encode_sequence, #encode_tagged_integer, #encode_tlv, #integer_to_octets
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.
279 280 281 |
# File 'lib/snmp/pdu.rb', line 279 def source_ip @source_ip end |
Instance Method Details
#encode ⇒ Object
271 272 273 |
# File 'lib/snmp/pdu.rb', line 271 def encode encode_pdu(BER::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.
286 287 288 289 290 291 292 293 |
# File 'lib/snmp/pdu.rb', line 286 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.
300 301 302 303 304 305 306 307 |
# File 'lib/snmp/pdu.rb', line 300 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 |