Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

net snmp - Issue sending SNMPv3 trap with the command snmptrap

I need to send a trap using the snmptrap command.

  1. If I use SNMPv1 the trap is sent:
snmptrap -v 1 -c public localhost EXAMPLE-MIB::MyTestFFAlarmTrap  localhost 4 0 '' EXAMPLE-MIB::trapType i 1 
EXAMPLE-MIB::trapTimeStamp t 500 
EXAMPLE-MIB::trapID s "device-1" 
EXAMPLE-MIB::trapCode i 3 
EXAMPLE-MIB::trapDescription s "Power alarm"
  1. If I use SNMPv3 the trap is not sent. I know the configuration is correct because I am sending these same traps from an SNMP agent using SNMPv3 and it works.

I only have the problem when sending them with the snmptrap command.

  • Option 1:
snmptrap -v3 -e 0x0102030405 -u usr1 -a SHA -A "12345678" -x DES -X "12345678" localhost   1000 EXAMPLE-MIB::MyTestFFAlarmTrap  localhost 4 0 '' EXAMPLE-MIB::trapType i 1 
EXAMPLE-MIB::trapTimeStamp t 500 
EXAMPLE-MIB::trapID s "device-1" 
EXAMPLE-MIB::trapCode i 3 
EXAMPLE-MIB::trapDescription s "Power alarm"

The screen shows the error:

localhost: Unknown Object Identifier (Sub-id not found: (top) -> localhost)
  • Option 2:
snmptrap -v3 -e 0x0102030405 -u usr1 -a SHA -A "12345678" -x DES -X "12345678" localhost 4 0 '' EXAMPLE-MIB::MyTestFFAlarmTrap  localhost 4 0 '' EXAMPLE-MIB::trapType i 1 
EXAMPLE-MIB::trapTimeStamp t 500 
EXAMPLE-MIB::trapID s "device-1" 
EXAMPLE-MIB::trapCode i 3 
EXAMPLE-MIB::trapDescription s "Power alarm"

The screen shows the error:

: Unknown Object Identifier (Sub-id not found: (top) -> )
  • Option 3:
snmptrap -v3 -e 0x0102030405 -u usr1 -a SHA -A "12345678" -x DES -X "12345678" localhost '' EXAMPLE-MIB::MyTestFFAlarmTrap  localhost 4 0 '' EXAMPLE-MIB::trapType i 1 
EXAMPLE-MIB::trapTimeStamp t 500 
EXAMPLE-MIB::trapID s "device-1" 
EXAMPLE-MIB::trapCode i 3 
EXAMPLE-MIB::trapDescription s "Power alarm"

The screen shows the error:

localhost: Unknown Object Identifier (Sub-id not found: (top) -> localhost)
  • Option 4:
snmptrap -v3 -e 0x0102030405 -u usr1 -a SHA -A "12345678" -x DES -X "12345678" 127.0.0.1 '' EXAMPLE-MIB::MyTestFFAlarmTrap  localhost 4 0 '' EXAMPLE-MIB::trapType i 1 
EXAMPLE-MIB::trapTimeStamp t 500 
EXAMPLE-MIB::trapID s "device-1" 
EXAMPLE-MIB::trapCode i 3 
EXAMPLE-MIB::trapDescription s "Power alarm"

The screen shows the error:

localhost: Unknown Object Identifier (Sub-id not found: (top) -> localhost)

I have checked the syntax of the snmptrap command in a tutorial or forum that I have found on the internet and I do not see the reason for the error.

I appreciate any help.

question from:https://stackoverflow.com/questions/66061758/issue-sending-snmpv3-trap-with-the-command-snmptrap

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...