[SNMP4J] Microsoft OIDs not working
rashi malviya
rashi.mlv at gmail.com
Fri Oct 3 08:02:20 CEST 2008
Hello SNMP4J users,
I'm using the SNMP4J library to monitor the various CPU, Memory, Network
statistics. Tool works fine for the generic OIDs but for the Microsoft
specific OIDs (1.3.6.1.4.1.311.1.1.3.1.1.3.1.4)its not working. I am
attaching my test code here.
For the first two OIDs its giving the result but for the 3rd one, the output
is something like this..
PDU Resopnse is : RESPONSE[requestID=1779867673, errorStatus=Success(0),
errorIndex=0, VBS[1.3.6.1.2.1.25.3.3.1.2.2 = 4; 1.3.6.1.2.1.25.2.2.0 =
2088428;* 1.3.6.1.4.1.311.1.9 = endOfMibView]*]
Any help will be appreciated.
Thanks in advance.
public class MySNMP {
PDU requestPDU = null;
Snmp snmp = null;
CommunityTarget target = null;
String responseString = null;
Address targetAddress = GenericAddress.parse("udp:127.0.0.1/161");
public MySNMP() throws IOException, InterruptedException {
PDU requestPDU = null;
String responseString = null;
Address targetAddress = GenericAddress.parse("udp:127.0.0.1/161");
TransportMapping transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
transport.listen();
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setAddress(targetAddress);
target.setRetries(2);
target.setTimeout(1500);
target.setVersion(SnmpConstants.version2c);
// creating PDU
PDU pdu = new PDU();
pdu.add(new VariableBinding(new OID(new int[]
{1,3,6,1,2,1,25,3,3,1,2})));
pdu.add(new VariableBinding(new OID(new int[]
{1,3,6,1,2,1,25,2,2})));
//OID not working
pdu.add(new VariableBinding(new OID(new int[]
{1,3,6,1,4,1,311,1,7,3,1,13,0})));
pdu.setType(PDU.GETNEXT);
// sending request
ResponseListener listener = new ResponseListener() {
public void onResponse(ResponseEvent event) {
((Snmp)event.getSource()).cancel(event.getRequest(), this);
System.out.println("PDU Resopnse is :
"+event.getResponse());
}
};
snmp.sendPDU(pdu, target, null, listener);
Thread.currentThread().sleep(30000);
}
public static void main(String[] args) throws IOException,
InterruptedException {
MySNMP objMySNMP = new MySNMP();
}
More information about the SNMP4J
mailing list