Discussion:
Generating v2c traps using snmptrap
r***@cisco.com
2002-09-04 20:15:09 UTC
Permalink
Could you pl tell mw how a v2c trap can be generated
using net-snmp snmptrap application?

The man page is quite confusing on this:

NAME
snmptrap, snmpinform - sends an SNMP trap to a manager

SYNOPSIS
snmptrap -v 1 [COMMON OPTIONS] [-Ci] enterprise-oid agent
generic-trap specific-trap uptime [OID TYPE VALUE]...

snmptrap -v [2c|3] [COMMON OPTIONS] [-Ci] uptime trap-oid
[OID TYPE VALUE]...


Clearly, there is no specification of the NMS address or the agent address.

Thanks,

Rk
x77309

bash$ cd netsnmp/bin
bash$ snmptrap -v 1 -c public 171.69.69.42 1.3.6.1.4.1.9.9.171.2.0.1 171.69.68.60 0 1 4567 1.3.6.1.4.1.9.9.171.1.2.1.1 i 1
$
(success)

bash$ snmptrap -v 2c -c public 171.69.69.42 1.3.6.1.4.1.9.9.171.2.0.1 171.69.68.60 0 1 4567 1.3.6.1.4.1.9.9.171.1.2.1.1 i 1
Segmentation Fault (core dumped)
$

bash$ snmptrap -v 2c -c public 4567 1.3.6.1.4.1.9.9.171.2.0.1 1.3.6.1.4.1.9.9.171.1.2.1.1 i 1
i: Missing type/value for variable
Erik Christiansen
2002-09-04 23:44:04 UTC
Permalink
Post by r***@cisco.com
Could you pl tell mw how a v2c trap can be generated
using net-snmp snmptrap application?
snmptrap -v [2c|3] [COMMON OPTIONS] [-Ci] uptime trap-oid
[OID TYPE VALUE]...
Clearly, there is no specification of the NMS address or the agent address.
Err.., could you please be a little more clear about what is unclear?
OPTIONS
snmptrap takes the common options described in the snm­
pcmd(1) manual page in addition to the -Ci option
described above.
<<<

and in man snmpcmd, under the heading "AGENT SPECIFICATION" there is a heap
of stuff relating to TCP protocol, host address, port, etc.

Is your "NMS address" included in this?

Regards,
Erik
Dave Shield
2002-09-06 06:51:03 UTC
Permalink
Post by r***@cisco.com
Could you pl tell mw how a v2c trap can be generated
using net-snmp snmptrap application?
NAME
snmptrap, snmpinform - sends an SNMP trap to a manager
SYNOPSIS
snmptrap -v 1 [COMMON OPTIONS] [-Ci] enterprise-oid agent
generic-trap specific-trap uptime [OID TYPE VALUE]...
snmptrap -v [2c|3] [COMMON OPTIONS] [-Ci] uptime trap-oid
[OID TYPE VALUE]...
Clearly, there is no specification of the NMS address or the agent address.
The NMS (i.e. trap destination) address is part of the "common options"
in both cases. You are correct that the v2 trap does not mention
the agent address. This is because that information is passed as
one of the (optional) varbinds appended to the main varbind list.
So you'd specify this information as part of the normal list of
[OID TYPE VALUE] triplets.
See RFC 2576, section 3.1 (4) for details.
Post by r***@cisco.com
bash$ cd netsnmp/bin
bash$ snmptrap -v 1 -c public 171.69.69.42 1.3.6.1.4.1.9.9.171.2.0.1
171.69.68.60 0 1 4567 1.3.6.1.4.1.9.9.171.1.2.1.1 i 1
$
(success)
bash$ snmptrap -v 2c -c public 171.69.69.42 1.3.6.1.4.1.9.9.171.2.0.1
171.69.68.60 0 1 4567 1.3.6.1.4.1.9.9.171.1.2.1.1 i 1
Segmentation Fault (core dumped)
Well, it shouldn't core dump, but that's completely the wrong syntax
for a v2 trap.
Post by r***@cisco.com
$
bash$ snmptrap -v 2c -c public 4567 1.3.6.1.4.1.9.9.171.2.0.1
1.3.6.1.4.1.9.9.171.1.2.1.1 i 1
i: Missing type/value for variable
You're missing the destination address for the trap.
Try

$ snmptrap -v 2c -c public 171.69.69.42
4567 1.3.6.1.4.1.9.9.171.2.0.1
1.3.6.1.4.1.9.9.171.1.2.1.1 i 1

(all on one line, of course).

or see http://www.net-snmp.org/tutorial/commands/snmptrap.html
for more discussion of this.

Dave

Loading...