[SNMP4J] Need OID for querying SNMP for CPU usage, etc. in Win XP

Manuneethi Shanmugam manuneethi-s at hcl.com
Wed Dec 22 07:31:50 CET 2010


Hi,
 I removed dot (".") in OIDs, but it's not working, please let me know any other way to resolve this issue.

Regards,
Manuneethi.

-----Original Message-----
From: snmp4j-bounces at agentpp.org [mailto:snmp4j-bounces at agentpp.org] On Behalf Of Frank Fock
Sent: Wednesday, December 22, 2010 5:43 AM
To: snmp4j at agentpp.org
Subject: Re: [SNMP4J] Need OID for querying SNMP for CPU usage, etc. in Win XP

Hi,

OIDs do NOT start with a dot (".").
May be that's causing the trouble.

Best regards,
Frank

On 21.12.2010 14:36, Manuneethi Shanmugam wrote:
> 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 retrieve 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);
>
>
> Regards,
> Manuneethi .S
>
>
> ________________________________
> ::DISCLAIMER::
> -----------------------------------------------------------------------------------------------------------------------
>
> The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
> It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
> this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
> Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
> this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
> received this email in error please delete it and notify the sender immediately. Before opening any mail and
> attachments please check them for viruses and defect.
>
> -----------------------------------------------------------------------------------------------------------------------
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com

_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j




More information about the SNMP4J mailing list