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

20,089

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.

Share:
20,089
Oscar Foley
Author by

Oscar Foley

Founder & director of Anedum Ltd, working as Big Data & DevOps contractor, currently in a contract for Reed Business Information in ProAgrica project using HPCC, ECL, Jenkins, Bash & PowerShell.

Updated on July 13, 2022

Comments

  • Oscar Foley
    Oscar Foley almost 2 years

    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?

  • Oscar Foley
    Oscar Foley over 11 years
    My vm has only on cpu. In my Ireasoning MIB browser I went to OID hrProcessorLoad (.1.3.6.1.2.1.25.3.3.1.2) and works (it is giving average over last minute). But in my code, snmp.get is returning null
  • dangowans
    dangowans over 11 years
    I'm not super familiar with MIB Browser, but I think there's a raw text output when you do your SNMP calls. I wonder if it is doing the SNMP Next call for you.
  • Oscar Foley
    Oscar Foley over 11 years
    GetNext worked fine. Sometimes CPULoad is in .1.3.6.1.2.1.25.3.3.1.2.7 others in .1.3.6.1.2.1.25.3.3.1.2.6 so I do a GetNext in the upper level GetNext(".1.3.6.1.2.1.25.3.3.1.2") and got it. Thanks.
  • dangowans
    dangowans over 11 years
    SNMP definitely has its quirks. Glad to hear you found what you were looking for.
  • Raul Chiarella
    Raul Chiarella over 2 years
    So when you do the GetNext the first one is the total CPU usage? And the other ones are the other cores?