IPWorks SNMP 2020 Node.js Edition

Questions / Feedback?

SendTrap Method

Sends an SNMP Trap.

Syntax

snmpagent.sendTrap(remoteHost, trapOID, [callback])

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for this method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

Depending upon the value of the SNMPVersion property, the packet is constructed as an SNMPv1 or SNMPv2 Trap PDU. The following configuration settings provide more control about how traps are generated: TrapPort, TrapAgentAddress, TrapCommunity, TrapEnterprise. The SysUpTime property provides the trap timestamp.

SendTrap sends an unauthenticated trap. The SendSecureTrap method is used to send authenticated SNMPv3 traps.

If any values are provided in the Objects collection, they are sent unchanged. In the case of an SNMPv2 or SNMPv3 Trap, if Objects has a count that is equal to 0, the following values are set: sysUpTime.0 equal to SysUpTime and snmpTrapOID.0 equal to TrapOID.

For SNMPv2 and SNMPv3 Traps, TrapOID must contain the full OID of the Trap. For SNMPv1, TrapOID must be a string of the form "generic.specific" where generic and specific are numeric values providing the Trap Generic Type and Specific Type.

For SNMPv1, TrapOID must be of the form "GenericTrap.SpecificTrap". These values are sent in the PDU header. TrapAgentAddress and TrapEnterprise are taken from the corresponding configuration settings.

Additionally, the following symbolic values are recognized and translated as follows:

Trap Name OID (SNMPv2 and above) SNMPv1 GenericType
coldStart 1.3.6.1.6.3.1.1.5.1 0
warmStart 1.3.6.1.6.3.1.1.5.2 1
linkDown 1.3.6.1.6.3.1.1.5.3 2
linkUp 1.3.6.1.6.3.1.1.5.4 3
authenticationFailure 1.3.6.1.6.3.1.1.5.5 4
egpNeighborLoss 1.3.6.1.6.3.1.1.5.6 5
enterpriseSpecific 1.3.6.1.6.3.1.1.5.7 6

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks SNMP 2020 Node.js Edition - Version 20.0 [Build 8202]