Good afternoon
I am trying to send a trap message to a server listening for snmp
messages but when I try to send the trap an exception is throwed:
16:20:12,817 ERROR [STDERR] org.snmp4j.MessageException: Message
processing model 3 returned error: Unsupported security model
16:20:12,817 ERROR [STDERR] at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:465)
16:20:12,818 ERROR [STDERR] at
org.snmp4j.Snmp.sendMessage(Snmp.java:1067)
16:20:12,818 ERROR [STDERR] at org.snmp4j.Snmp.send(Snmp.java:882)
16:20:12,818 ERROR [STDERR] at org.snmp4j.Snmp.send(Snmp.java:875)
16:20:12,818 ERROR [STDERR] at org.snmp4j.Snmp.send(Snmp.java:840)
16:20:12,818 ERROR [STDERR] at
com.elaide.crypto.ext.web.snmp.TrapSnmp.sendTrap(TrapSnmp.java:94)
16:20:12,818 ERROR [STDERR] at
com.elaide.crypto.ext.web.snmp.TrapSnmp.createAndSend(TrapSnmp.java:42)
16:20:12,818 ERROR [STDERR] at
com.elaide.crypto.ext.web.listeners.IndexListener.loadUserManager(IndexListener.java:47)
16:20:12,818 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:20:12,818 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:20:12,818 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:20:12,818 ERROR [STDERR] at
java.lang.reflect.Method.invoke(Method.java:597)
16:20:12,818 ERROR [STDERR] at bsh.Reflect.invokeMethod(Unknown Source)
16:20:12,818 ERROR [STDERR] at
bsh.Reflect.invokeObjectMethod(Unknown Source)
16:20:12,818 ERROR [STDERR] at bsh.Name.invokeMethod(Unknown Source)
16:20:12,818 ERROR [STDERR] at bsh.BSHMethodInvocation.eval(Unknown
Source)
16:20:12,818 ERROR [STDERR] at bsh.BSHPrimaryExpression.eval(Unknown
Source)
16:20:12,819 ERROR [STDERR] at bsh.BSHPrimaryExpression.eval(Unknown
Source)
16:20:12,819 ERROR [STDERR] at bsh.Interpreter.eval(Unknown Source)
16:20:12,819 ERROR [STDERR] at bsh.Interpreter.eval(Unknown Source)
16:20:12,819 ERROR [STDERR] at
org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:134)
16:20:12,819 ERROR [STDERR] at
org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:341)
16:20:12,819 ERROR [STDERR] at
org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:840)
16:20:12,819 ERROR [STDERR] at
org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:175)
16:20:12,819 ERROR [STDERR] at
org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:140)
16:20:12,819 ERROR [STDERR] at
org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process0(EventProcessingThreadImpl.java:517)
16:20:12,819 ERROR [STDERR] at
org.zkoss.zk.ui.impl.EventProcessingThreadImpl.run(EventProcessingThreadImpl.java:444)
I've searched for two days a solution in the snmp4j documentation and
over internet but no luck. Do you have an idea?
I'm attaching my simple snmp class.
Thanks in advance
--
Gian Marco Gallo
Elaide SRL
Email: gianmarco.ga...@elaide.com
Phone: +39 049 4102390
package com.elaide.crypto.ext.web.snmp;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.snmp4j.ScopedPDU;
import org.snmp4j.Snmp;
import org.snmp4j.UserTarget;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.security.SecurityLevel;
import org.snmp4j.security.SecurityModel;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.OctetString;
import org.snmp4j.transport.DefaultUdpTransportMapping;
/*//////////////////////////////////////////////////
/ CAUTION: ALL THIS CLASS SHOULD BE TRANSLATED /
//////////////////////////////////////////////////*/
public class TrapSnmp {
Address address;
UserTarget target;
ScopedPDU pdu;
Snmp snmp;
private static Logger log;
public TrapSnmp() {
log = Logger.getLogger(TrapSnmp.class);
}
public void createAndSend() {
createAddress();
createPDU();
createTarget();
sendTrap();
}
private void createAddress() {
log.info("Creating the SNMP destination address");
address = GenericAddress.parse("udp:192.168.5.11/161");
}
private void createPDU() {
log.info("Creating the TRAP message");
pdu = new ScopedPDU();
pdu.setType(ScopedPDU.TRAP);
pdu.setContextName(new OctetString("CryptoExtWeb problem"));
log.info("The trap has been created with this values: ");
log.info("Context name: "+pdu.getContextName());
log.info("Context engine ID: "+pdu.getContextEngineID());
log.info("Request ID: "+pdu.getRequestID());
log.info("Type: "+pdu.getType());
}
private void createTarget() {
log.info("Creating the destination target");
target = new UserTarget();
target.setAddress(address);
target.setRetries(1);
target.setTimeout(2000);
target.setSecurityModel(SecurityModel.SECURITY_MODEL_USM);
target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
target.setSecurityName(new OctetString("CryptoExtWeb target"));
target.setVersion(SnmpConstants.version3);
log.info("The destination target has been created with this
values: ");
log.info("Version: "+target.getVersion());
log.info("Address: "+target.getAddress());
log.info("Security name: "+target.getSecurityName());
log.info("Security level: "+target.getSecurityLevel());
}
private void sendTrap() {
try {
log.info("Preparing the trap to send");
snmp = new Snmp(new DefaultUdpTransportMapping());
snmp.listen();
log.info("Sending the trap");
snmp.send(pdu, target);
log.info("Trap sent");
}
catch(IOException ioe) {
log.error("IOException throwed by the
DefaultUdpTransportMapping");
ioe.printStackTrace();
}
}
}
_______________________________________________
SNMP4J mailing list
SNMP4J@agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j