Need OID for querying SNMP for CPU usage,etc. in Win XP
Hi,I am unable to get the details(CPU Util,Swap Util) from windows machine using SNMP(SNMP4j.jar). The SNMP service is running on the target Windows XP system.Where can I find the correct OID for windows XP to retreive these parameters?Attaching code below:import org.snmp4j.CommunityTarget;import org.snmp4j.PDU;import org.snmp4j.Snmp;import org.snmp4j.event.ResponseEvent;import org.snmp4j.mp.SnmpConstants;import org.snmp4j.smi.OID;import org.snmp4j.smi.OctetString;import org.snmp4j.smi.UdpAddress;import org.snmp4j.smi.VariableBinding;import org.snmp4j.transport.DefaultUdpTransportMapping; // configure Snmp object private Snmp snmp = null; private UdpAddress targetAddress = null; private CommunityTarget target = null; ResponseEvent responseEvent = null; targetAddress = new UdpAddress(10.101.210.127 + '/' + 161);target = new CommunityTarget(); target.setCommunity(new OctetString("public")); target.setAddress(targetAddress); target.setRetries(2); target.setTimeout(60000); target.setVersion(SnmpConstants.version2c); snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.listen(); //CPU usage code PDU command = new PDU(); command.setType(PDU.GET); command.add(new VariableBinding(new OID(".1.3.6.1.2.1.25.2.3.1.4")));// Percentage of Idle CPU time//.1.3.6.1.4.1.311.1.7.3.1.6.0 try { responseEvent = snmp.send(command, target);//.1.3.6.1.4.1.2021.11.11.0 } catch (Exception e) { System.out.println("Exception : " + e); e.printStackTrace(); } if (responseEvent.getResponse() == null) { // request timed out return null; } else { // dump response PDU PDU pdu = (responseEvent.getResponse()); Vector Output = new Vector(); Output = pdu.getVariableBindings(); int val1 = 0; double CPUMemUtil = 0; String str = null; str = Output.get(0).toString(); String Spstr[] = str.split("="); Spstr[1] = Spstr[1].trim(); try { val1 = Integer.parseInt(Spstr[1]); } catch (Exception e) { System.out.println("Exception occurred" + e); e.printStackTrace(); } CPUMemUtil = (100 - val1); String OutputMemUtil = Double.toString(CPUMemUtil); System.out.println("CPU usage"+OutputMemUtil); Thanks in advance,Manuneethi1 person got this answerI do too
December 21st, 2010 4:34pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics