SNMP Trap Event
Event that fires when the server receives an SNMP trap.
Request
-
Subscribe
-
Unsubscribe
cn.emit('add-topics', 'snmp-trap')
cn.emit('remove-topics', 'snmp-trap')
Response
Response contains the Event Log entry.
Field | Type | Description |
---|---|---|
_id |
String |
ID of the entry. |
type |
Integer |
Message type. |
agentId |
String |
Agent that generated the SNMP trap. |
payload |
Object |
SNMP Trap payload. |
timestamp |
Integer |
Timestamp of receiving the SNMP trap. |
level |
Integer |
|
entity |
Object |
Entity that the SNMP trap belongs to. |
entity.entityId |
String |
ID of the entity. |
entity.entityName |
String |
Name of the entity. |
entity.entityType |
Integer |
Example
Request
-
NodeJS
const comet = require('socket.io-client');
// Comet settings
const COMET_CONNECT_TIMEOUT = 5000;
const sessionId = "..."
const conf = {
cometHost: 'https://example.com',
cometPort: '1234',
};
const url = `${conf.cometHost}` + (conf.cometPort ? `:${conf.cometPort}` : '');
const cn = comet.connect(url, {
query: { forceNew: true, sessionId },
timeout: COMET_CONNECT_TIMEOUT,
});
cn.emit('add-topics', 'snmp-trap');
cn.on('snmp-trap', msg => {
console.log(msg);
});
Response
{
"type":1,
"agentId":"817",
"payload":{
"senderAddress":"127.0.0.1",
"enterpriseOid":".1.3.6.1.4.1.5089.1.0.1",
"agentAddress":"127.0.0.1",
"genericTrap":1,
"specificTrap":1,
"bindings":{
".1.3.6.1.4.1.5089.2.0.99":"\"TEST TEST\""
},
"trapOid":".1.3.6.1.4.1.5089.2.0.99",
"text":"\"TEST TEST\""
},
"timestamp":1668076145997,
"level":2,
"entity":{
"entityId":"5ac3a4b2a9fd5c3965dac350",
"entityType":1,
"entityName":"SNMP TRAP"
},
"_id":"636cd2738044c648802c2e8a"
}