[SNMP4J] (no subject)
RobertoBouza at bayviewfinancial.com
RobertoBouza at bayviewfinancial.com
Thu Apr 5 00:09:36 CEST 2007
Hello everyone,
I'm getting this Exception:
org.snmp4j.transport.UnsupportedAddressClassException: Unsupported address
class (transport mapping): org.snmp4j.smi.IpAddress
I'm pretty new to SNMP and developing using SNMP4J. I just want to make a
SNMP get of an OID variable from a server and I get this error when the
send methos is called on the snmp class. Here is the code:
Any help would be really appreciated.
###########
public class GetMIBValue {
public static void main(String arg[]) {
try {
TransportMapping transport = new
DefaultTcpTransportMapping();
Snmp snmp = new Snmp(transport);
// Since we are using SNMPv3 we use authenticated users
this is handled by the UsmUser and USM class
UsmUser uu = new UsmUser(new OctetString("ssnmpreader"),
AuthMD5.ID, new OctetString("ssnmpread3r"), PrivDES.ID, new
OctetString("ssnmpread3r"));
if (uu == null) {
System.out.println("Null UsmUser");
} else {
System.out.println("Valid UsmUser");
}
USM usm = snmp.getUSM();
if (usm == null) {
System.out.println("Null Usm");
} else {
usm = new USM(SecurityProtocols.getInstance(), new
OctetString(MPv3.createLocalEngineID()), 0);
usm.addUser(new OctetString("ssnmpreader"), uu);
System.out.println("Valid Usm");
}
UserTarget target = new UserTarget();
IpAddress ipa = new IpAddress("10.10.32.201");
target.setAddress(ipa);
if (target.getAddress().isValid()) {
System.out.println("Valid IP address");
} else {
System.out.println("Invalid IP address");
}
target.setRetries(1);
// set timeout to 500 milliseconds -> 2*500ms = 1s total
timeout
target.setTimeout(500);
target.setVersion(SnmpConstants.version3);
target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
target.setSecurityName(new OctetString("MD5DES"));
// We create the basic PDU Unit
ScopedPDU pdu = new ScopedPDU();
pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.1.1")));
pdu.setType(PDU.GET);
// set non-default context engine ID (to use targets
authoritative engine ID
// use an empty (size == 0) octet string)
pdu.setContextEngineID(new
OctetString("0x80001f88803d4bf37386c41346"));
ResponseEvent response = snmp.send(pdu, target);
PDU responsePDU = response.getResponse();
if (responsePDU == null) {
} else {
System.out.println("Received response from: "+
response.getPeerAddress());
System.out.println(responsePDU.toString());
}
} catch (Exception exp) {
System.out.println(exp.toString());
System.out.println("-----------");
exp.printStackTrace();
}
}
}
########################
---
Roberto Bouza
Middle Tier Administrator II
Bayview Financial, L.P.
4425 Ponce de Leon Blvd, 2nd Floor
Coral Gables, FL 33146
Ph. 305-644-2550
More information about the SNMP4J
mailing list