[SNMP4J] able to rreceive V1 trap but not V3 trap...................
sanjay A
sandy1977r at gmail.com
Mon Jul 16 07:36:06 CEST 2007
*Hi *
* *When I send a V1 trap by "SNMP4J -p V1TRAP -v 1......" utility ,I am able
to receive v1 trap, but not able to receive v3 trap by "
SNMP4J -p TRAP -v 3 -u aSecurityName....." . I can get these v3 trap through
"SNMP4J -u aSecurityName -Ol 0.0.0.0/162" utility .
I have gone through the snmp4j doc and mailing list, but couldn't find
anything.....
So please give me any idea in my code for V3 trap.....
Awaiting for the reply.....
*public* *class* V1trapListen {
*public* V1trapListen() { }
*public* *synchronized* *void* start(String address) *throws*Exception {
UdpAddress listenAddress = *new* UdpAddress(address);
ThreadPool threadPool = ThreadPool.*create*("DispatcherPool",
2);//1
MessageDispatcher mtDispatcher =
*new*MultiThreadedMessageDispatcher(threadPool,
*new* MessageDispatcherImpl());//2
mtDispatcher.addMessageProcessingModel(*new* MPv1());
mtDispatcher.addMessageProcessingModel(*new* MPv2c());
mtDispatcher.addMessageProcessingModel(*new* MPv3());
SecurityProtocols.*getInstance*().addDefaultProtocols();
Snmp snmp = *new* Snmp(mtDispatcher);
CommandResponder trapPrinter = *new* CommandResponder() {
*public* *void* processPdu(CommandResponderEvent e) {
PDU command = e.getPDU();
*if* (command != *null*) {
System.*out*.println("\n"+e.getPDU()); } }};
*if* (snmp.addNotificationListener(listenAddress,
trapPrinter)) {
snmp.listen();
System.*out*.println("snmp.addNotificationListenerreturned TRUE "
);
System.*out*.println("Waiting for [trap] on "
+listenAddress.toString());
*try* { *this*.wait();}
*catch*(InterruptedException ex) {
System.*out*.println("Caught
InterruptException: "+ex.toString());
}
*catch*(Exception ex) {
System.*out*.println("CaughtException:
"+ex.toString());
}
} *else* {System.*out*.println("
snmp.addNotificationListener returned FALSE");
}
}
*public* *static* *void* main(String [ ] args) {
String address = *null*;
*if* (args.length > 0) {
address = args[0];
}
*if* (address == *null* || address.equals("")) {
address = "127.0.0.1/16200";
}
V1trapListen trap = *new* V1trapListen();
*try* {
trap.start(address);
} *catch* (Exception ex) {
System.*out*.println("CaughtException: "
+ex.toString());
}
}
}
with best regards
Sandy
More information about the SNMP4J
mailing list