Sending Snmp2 Trap Message from Linux Command Lne

Send a notification trap SNMP with snmptrap command Linux

The syntax is pretty simple:

snmptrap -c public -v 2c 127.0.0.1 "" 1.3.6.1.2.1.43.18.2.0.1

The problem here is that this particular trap should be sent with 6 varbinds:

  • prtAlertIndex
  • prtAlertSeverityLevel
  • prtAlertGroup
  • prtAlertGroupIndex
  • prtAlertLocation
  • prtAlertCode

Thus you'll also have to provide values for all these varbinds. So the Trap Receiver will be able to handle this type of trap properly.

I'd suggest using tools like NetDecision Trap Simulator which automatically configures traps to send based on MIB definitions.

Sample Image

Anything wrong with this trap message?

This is pretty normal Enterprise specific SNMP notification. The type of this notification (PDU format) is TRAPv2. This trap contains 3 varbinds. The first two are required by RFC1448. So you cannot get rid of them.

  • The first varbind snmpTrapOID.0 is the actual Object Identifier (OID) that identifies the type of Trap.
  • The second varbind sysUptime.0 is from RFC1213 (MIB-2). Basically it is the time since device was last rebooted.

I would add .0 to cpsSystemSendTrap as it is a scalar object.

how to capture trap message in net-snmp

Netsnmp provides Snmptrapd for this purpose.

It is an application which can listen on a port (default 162) on a host for traps and will log those that are received.

//EDIT ...

Here is an example ...

snmptrapd -f -m +ALL -Lo  -c /tmp/snmptrapd.conf 9876

where /tmp/snmptrapd.conf only contains one line which for simplicity disables community/password checking

disableAuthorization yes

Use man snmptrapd to see what the flags/arguements mean.



Related Topics



Leave a reply



Submit