Created
June 9, 2020 10:21
-
-
Save jsenin/0de5475d092c916885acf85671309871 to your computer and use it in GitHub Desktop.
understand snmp hex values to extract date time values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extract values using snmp-walk | |
# filter by dates 07E4 -> 2020 year | |
snmpwalk -v2c -c community gpon.my.net 1.3.6.1.4.1.2011.6.128.1.1.2 | grep "07 E4" | |
# mibs from https://code.getnoc.com/noc/noc/-/blob/master/cmibs/huawei_xpon_mib.py | |
"HUAWEI-XPON-MIB::hwGponDeviceOltLastUpTime": "1.3.6.1.4.1.2011.6.128.1.1.2.21.1.17", | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.21.1.17.4194304000 = Hex-STRING: 07 E4 06 09 0A 2E 07 00 2B 02 00 | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.21.1.17.4194304768 = Hex-STRING: 07 E4 02 13 0A 0E 00 00 2B 01 00 | |
"HUAWEI-XPON-MIB::hwGponDeviceOltLastDownTime": "1.3.6.1.4.1.2011.6.128.1.1.2.21.1.18", | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.21.1.18.4194304000 = Hex-STRING: 07 E4 06 09 0A 2D 38 00 2B 02 00 | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.21.1.18.4194304768 = Hex-STRING: 07 E4 02 13 11 30 38 00 2B 01 00 | |
"HUAWEI-XPON-MIB::hwGponDeviceOntControlLastUpTime": "1.3.6.1.4.1.2011.6.128.1.1.2.46.1.22", | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.46.1.22.4194304000.0 = Hex-STRING: 07 E4 06 09 0A 2E 09 00 2B 02 00 | |
"HUAWEI-XPON-MIB::hwGponDeviceAutoFindOntInfoOntAutoFindTime": "1.3.6.1.4.1.2011.6.128.1.1.2.48.1.8", | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.48.1.8.4194304000.0 = Hex-STRING: 07 E4 04 0F 0F 0B 14 00 2B 02 00 | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.48.1.8.4194304000.1 = Hex-STRING: 07 E4 06 08 11 1C 23 00 2B 02 00 | |
"HUAWEI-XPON-MIB::hwGponDeviceOntRegisterTime": "1.3.6.1.4.1.2011.6.128.1.1.2.52.1.4", | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.52.1.4.4194304000.0 = Hex-STRING: 07 E4 02 11 11 0F 08 00 2B 01 00 | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.52.1.4.4194304000.1 = Hex-STRING: 07 E4 06 08 11 1C 23 00 2B 02 00 | |
import struct | |
ts = [ | |
'\x07\xE4\x06\x09\x0A\x2E\x07\x00\x2B\x02\x00', | |
'\x07\xE4\x02\x13\x0A\x0E\x00\x00\x2B\x01\x00', | |
'\x07\xE4\x06\x09\x0A\x2D\x38\x00\x2B\x02\x00', | |
'\x07\xE4\x02\x13\x11\x30\x38\x00\x2B\x01\x00', | |
'\x07\xE4\x06\x09\x0A\x2E\x09\x00\x2B\x02\x00', | |
'\x07\xE4\x04\x0F\x0F\x0B\x14\x00\x2B\x02\x00', | |
'\x07\xE4\x06\x08\x11\x1C\x23\x00\x2B\x02\x00', | |
'\x07\xE4\x02\x11\x11\x0F\x08\x00\x2B\x01\x00', | |
'\x07\xE4\x06\x08\x11\x1C\x23\x00\x2B\x02\x00', | |
] | |
for oct in ts: | |
struct.unpack('>HBBBBBBBBB', oct) | |
(2020, 6, 9, 10, 46, 7, 0, 43, 2, 0) | |
(2020, 2, 19, 10, 14, 0, 0, 43, 1, 0) | |
(2020, 6, 9, 10, 45, 56, 0, 43, 2, 0) | |
(2020, 2, 19, 17, 48, 56, 0, 43, 1, 0) | |
(2020, 6, 9, 10, 46, 9, 0, 43, 2, 0) | |
(2020, 4, 15, 15, 11, 20, 0, 43, 2, 0) | |
(2020, 6, 8, 17, 28, 35, 0, 43, 2, 0) | |
(2020, 2, 17, 17, 15, 8, 0, 43, 1, 0) | |
(2020, 6, 8, 17, 28, 35, 0, 43, 2, 0) | |
# year/month/day/hour/minute/second/0/decisecond/time zone/+ = 0, - = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment