How can I send snmpv2 traps from Java application. I tried to do example on snmp4j, but it didn't work.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I use SNMP4J for this.
This javadoc might help you write your code. You can use the Snmp.trap() method
Edit:
Well, I dont have code of my own at this moment, but you may refer this one . You have to use Snmp.notify() for sending V2 trap instead of Snmp.trap() as trap() only supports sending V1 traps.
I would go for snmp4j library http://www.snmp4j.org/.
A good example that sends trap V1 and notification V2. I just needed to modify the port to 162 and the way to set the sysUpTime for both version V1 and V2.
Tested with snmp4j-1.10.1 and snmp4j-2.1.0.
http://www.techdive.in/snmp/snmp4j-trap-sender
A very good example can be found here:
http://shivasoft.in/blog/java/snmp/create-snmp-client-in-java-using-snmp4j/
It took me some time but I finally figured out how to use SNMP4J to send a trap: Hope that helps..