今天在園區走了走,而後忽然想明白了幾天來思考的snmp trap的邏輯。結合若干工具node
把這個過程run成功。快速記錄下。併發
下載node-net-snmp 的源代碼庫,而後:工具
cd example
node snmp-receiver.js -v
複製代碼
其中-v表示輸出要羅嗦一點,這樣咱們纔看獲得具體的trap內容。spa
2020-4-9 17:46:09: TrapV2 received:
{
"pdu": {
"type": 167,
"id": 402812005,
"varbinds": [
{
"oid": "1.3.6.1.2.1.1.3.0",
"type": 67,
"value": 0
},
{
"oid": "1.3.6.1.6.3.1.1.4.1.0",
"type": 6,
"value": "1.3.6.1.4.1.66666.3"
},
{
"oid": "1.3.6.1.4.1.66666.1.1.0",
"type": 4,
"value": {
"type": "Buffer",
"data": [
97,
98,
99,
100
]
}
}
],
"scoped": false
},
"rinfo": {
"address": "127.0.0.1",
"family": "IPv4",
"port": 63984,
"size": 90
}
}
複製代碼
varbinds共三個,其中code
tbit DEFINITIONS ::= BEGIN
IMPORTS
enterprises, IpAddress, Integer32, Unsigned32, Counter64,
OBJECT-TYPE,NOTIFICATION-TYPE
FROM SNMPv2-SMI;
tbit OBJECT IDENTIFIER ::= { enterprises 66666 }
RecoDevice OBJECT IDENTIFIER ::= { tbit 1 }
RecoDevice1 OBJECT IDENTIFIER ::= { tbit 2 }
Name OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Description."
::= { RecoDevice 1 }
dataAlarmTrap NOTIFICATION-TYPE
OBJECTS { Name }
STATUS current
DESCRIPTION
"Description."
::= { tbit 3 }
END
複製代碼