How can I find what is OID for cpu usage in windows 7?

Oscar Foley picture Oscar Foley · Aug 12, 2012 · Viewed 19.2k times · Source

I have a vm with windows 7. I have installed windows snmp agent service. Then from my pc I have developed a small program in C# to communicate with SNMP agent using snmpsharpnet and works!

I used some sample OIDs like:

  • .1.3.6.1.2.1.1.1.0 to get system description
  • .1.3.6.1.2.1.25.1.6. to get number of processes

So my program works and I have correct network connectivity.

        string host = "192.168.1.92";
        string community = "public";
        SimpleSnmp snmp = new SimpleSnmp(host, community);

        if (!snmp.Valid)
        {
            Console.WriteLine("SNMP agent host name/ip address is invalid.");
            return;
        }
        Dictionary<Oid, AsnType> result = snmp.Get(SnmpVersion.Ver1, new string[] { ".1.3.6.1.2.1.25.3.3.1.2" }); 

        if (result == null)
        {
            Console.WriteLine("No results received.");
            Console.ReadKey();
            return;
        }

        foreach (KeyValuePair<Oid, AsnType>  kvp in result)
        {
            Console.WriteLine("{0}: {1} {2}", kvp.Key.ToString(),
                                  SnmpConstants.GetTypeName(kvp.Value.Type),
                                  kvp.Value.ToString());
        }
        Console.ReadKey();
    }

Now I am trying to get cpu load using .1.3.6.1.2.1.25.3.3.1.2 but I doen't work (got info from here). I have also installed a Mib Browser (from ireasoning.com) to learn correct OIDs.

My questions are:

  • Which is correct OID to get CPU Load from windows 7?

  • OID are not common for all systems, aren't them? I mean linux, windows, routers have their own OIDs?

  • Where can I find OIDs for windows 7?

Answer

dangowans picture dangowans · Aug 12, 2012

1.3.6.1.2.1.25.3.3.1.2 is part of the hrProcessorTable in the HOST-RESOURCES MIB. Using a tool like Mib Browser, do an SNMP Walk on the table OID, 1.3.6.1.2.1.25.3.3. Or, start on that OID and do an SNMP Next. If you for example have a dual-core CPU, the processor load for one of the cores may be in an OID like 1.3.6.1.2.1.25.3.3.1.2.1.