StorageGRID SNMP陷阱无法解码外部SNMP服务器上的时间
适用场景
- NetApp 存储网格
- 外部SNMP服务器
- BigPanda
问题描述
- StorageGRID SNMP陷阱已成功从NetApp发送到SNMP服务器、但未正确解码时间。
- SNMP陷阱在
activeAlertStartTime
外部SNMP服务器上显示的值不正确。
\net\sg-snmp-agent.log
Lumberjack中的输出示例、确认已成功发送SNMP陷阱:
[2023-05-08T14:34:14.806] INFO -- Sending alert notifications for .16.97.55.55.100.102.51.56.49.48.54.97.51.99.51.52.54, startsAt 2023-05-08T14:33:31.841Z
2023-05-08T14:34:14.807] INFO -- Sending SNMP v2c trap to IP_ADDRESS
[2023-05-08T14:34:15.110] INFO -- Sending SNMP v2c trap to IP_ADDRESS
预期时间输出示例:
NETAPP-STORAGEGRID-MIB::activeAlertStartTime."bccfd77ef76f44f7"= STRING: 2023-3-7,2:22:27.2,+0:0
OID: 1.3.6.1.4.1.789.28669.1.4.1.5.16.99.100.97.97.56.56.53.102.57.100.48.53.100.99.50.54 Value: 7.E6.8.C.E.13.14.6.2B.0.0
外部SNMP服务器上的示例:
SNMP_VERSION 1.3.6.1.4.1.789.28669.0.6 = v2
pysnmp.proto.rfc1902.TimeTicks 1.3.6.1.2.1.1.3.0 = 1692335151
pyasn1.type.univ.ObjectIdentifier 1.3.6.1.6.3.1.1.4.1.0 = 1.3.6.1.4.1.789.28669.0.6
pysnmp.proto.rfc1902.OctetString 1.3.6.1.4.1.789.28669.1.4.1.5.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51 = +
pysnmp.proto.rfc1902.OctetString 1.3.6.1.4.1.789.28669.1.4.1.3.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51 = NODE_NAME
pysnmp.proto.rfc1902.OctetString 1.3.6.1.4.1.789.28669.1.4.1.1.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51 = ea242568f21b58a3
pysnmp.proto.rfc1902.OctetString 1.3.6.1.4.1.789.28669.1.4.1.4.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51 = minor
pysnmp.proto.rfc1902.OctetString 1.3.6.1.4.1.789.28669.1.4.1.2.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51 = 'CPU usage test'
2023-03-03 10:26:41,917 translator.py 43 28799 DEBUG: got new SNMP trap notification
2023-03-03 10:26:41,917 translator.py 83 28799 DEBUG: oid: 1.3.6.1.2.1.1.3.0, symbol: sysUpTime, mib: SNMPv2-MIB, value: 1692335151
2023-03-03 10:26:41,917 translator.py 83 28799 DEBUG: oid: 1.3.6.1.6.3.1.1.4.1.0, symbol: snmpTrapOID, mib: SNMPv2-MIB, value: 1.3.6.1.4.1.789.28669.0.6
2023-03-03 10:26:41,917 translator.py 94 28799 DEBUG: protocol: v2, mib name: SNMPv2-MIB, symbol name: snmpTrapOID
2023-03-03 10:26:41,917 translator.py 83 28799 DEBUG: oid: 1.3.6.1.4.1.789.28669.1.4.1.5.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51, symbol: activeAlertStartTime, mib: NETAPP-STORAGEGRID-MIB, value: +
2023-03-03 10:26:41,918 translator.py 83 28799 DEBUG: oid: 1.3.6.1.4.1.789.28669.1.4.1.3.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51, symbol: activeAlertInstance, mib: NETAPP-STORAGEGRID-MIB, value: NODE_NAME
2023-03-03 10:26:41,918 translator.py 83 28799 DEBUG: oid: 1.3.6.1.4.1.789.28669.1.4.1.1.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51, symbol: activeAlertId, mib: NETAPP-STORAGEGRID-MIB, value: ea242568f21b58a3
2023-03-03 10:26:41,918 translator.py 83 28799 DEBUG: oid: 1.3.6.1.4.1.789.28669.1.4.1.4.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51, symbol: activeAlertSeverity, mib: NETAPP-STORAGEGRID-MIB, value: minor
2023-03-03 10:26:41,919 translator.py 83 28799 DEBUG: oid: 1.3.6.1.4.1.789.28669.1.4.1.2.16.101.97.50.52.50.53.54.56.102.50.49.98.53.56.97.51, symbol: activeAlertName, mib: NETAPP-STORAGEGRID-MIB, value: 'CPU usage test'
2023-03-03 10:26:41,919 translator.py 107 28799 DEBUG: trap oid: 1.3.6.1.4.1.789.28669.0.6, mib name: NETAPP-STORAGEGRID-MIB, symbol name: activeMinorAlert, payload: {'activeAlertSeverity': 'minor', 'activeAlertId': 'ea242568f21b58a3', 'sysUpTime': 1692335151, 'activeAlertInstance': 'NODE_NAME', 'activeAlertStartTime': '\x07\xe7\x03\x03\x10\x19\x1f\x08+\x00\x00', 'activeAlertName': "'CPU usage test'"}
BigPanda日志中的示例:
2023-05-08 09:34:15,165 manipulator.py 61 19952 DEBUG: before: {'activeAlertSeverity': 'minor', 'activeAlertId': 'a77df38106a3c346', 'sysUpTime': 24061459, 'activeAlertInstance': 'dub1sgsn02', 'activeAlertStartTime': '\x07\xe7\x05\x08\x0e!\x1f\x08+\x00\x00', 'activeAlertName': "'CPU usage test'"}
2023-05-08 09:34:15,165 manipulator.py 169 19952 DEBUG: added primary field. primary_property: activeAlertInstance
2023-05-08 09:34:15,165 manipulator.py 175 19952 DEBUG: added secondary field. secondary_property: activeAlertName
2023-05-08 09:34:15,165 manipulator.py 83 19952 DEBUG: manipulated: {u'Status': 'minor', 'secondary_property': 'activeAlertName', 'snmp_source_port': 32892, 'mib': 'NETAPP-STORAGEGRID-MIB', 'snmp_community': 'public', 'sysUpTime': 24061459, 'activeAlertSeverity': 'minor', 'activeAlertId': 'a77df38106a3c346', 'snmp_port': 162, 'snmp_source_ip': 'IP_ADDRESS', 'snmp_trap_name': 'activeMinorAlert', 'primary_property': 'activeAlertInstance', 'activeAlertInstance': 'dub1sgsn02', 'activeAlertStartTime': '\x07\xe7\x05\x08\x0e!\x1f\x08+\x00\x00', 'status': u'warning', 'trap': 'activeMinorAlert', 'activeAlertName': "'CPU usage test'", 'snmp_trap_version': 'v2', 'snmp_protocol': 'udp'}
2023-05-08 09:34:15,166 emitter.py 58 19952 ERROR: failed to write trap payload to disk. file path: /var/lib/bigpanda/queue/bp_68331baa-edad-11ed-9d02-005056a2809f.json, trap payload: {u'Status': 'minor', 'secondary_property': 'activeAlertName', 'snmp_source_port': '32892', 'mib': 'NETAPP-STORAGEGRID-MIB', 'snmp_community': 'public', 'sysUpTime': '24061459', 'activeAlertSeverity': 'minor', 'activeAlertId': 'a77df38106a3c346', 'snmp_port': '162', 'snmp_source_ip': 'IP_ADDRESS', 'snmp_trap_name': 'activeMinorAlert', 'primary_property': 'activeAlertInstance', 'activeAlertInstance': 'NODE_NAME', 'activeAlertStartTime': '\x07\xe7\x05\x08\x0e!\x1f\x08+\x00\x00', 'status': u'warning', 'trap': 'activeMinorAlert', 'activeAlertName': "'CPU usage test'", 'snmp_trap_version': 'v2', 'snmp_protocol': 'udp'}
2023-05-08 09:34:15,166 translator.py 67 19952 ERROR: failed to parse SNMP trap
Traceback (most recent call last):
File "/opt/bigpanda/bigpanda-snmpd/bp_snmpd/translator/translator.py", line 62, in translate
source, community, event_config=event_config)
File "/opt/bigpanda/bigpanda-snmpd/bp_snmpd/manipulator/manipulator.py", line 86, in manipulate
self._emitter.emit(trap_payload)
File "/opt/bigpanda/bigpanda-snmpd/bp_snmpd/emitter/emitter.py", line 54, in emit
dumps = json.dumps(trap_payload, indent=4, ensure_ascii=False, encoding=self.ENCODING)
File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
chunks = list(chunks)
File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
for chunk in _iterencode_dict(o, _current_indent_level):
File "/usr/lib64/python2.7/json/encoder.py", line 390, in _iterencode_dict
yield _encoder(value)
File "/usr/lib64/python2.7/json/encoder.py", line 233, in _encoder
o = o.decode(_encoding)
File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe7 in position 1: invalid continuation byte