views:

16

answers:

1

I am trying to use the Win32_PerfRawData_PerfOS_Processor class on a windows server enterprise 2007 remotely to find the CPU usage. But I am getting huge 14-15 digit values like 11745679223456 %. Any idea why it is giving erroneous result? It seems to work fine on my server 2008. Is there any way I can reinstall these classes?

P.S : I don't have the PerfFormattedData_Counters_ProcessorInfo class on my server 2007. Is ther any way I can install this class on it? Are there any other classes thta I can use to find CPU usage?

+1  A: 

I see from your previous questions that you know C#, so an easier alternative might be to instead use the PerformanceCounter class to get the data. One of the constructors accept a machine name so you should be able to use it remotely.

Here's a blog post that seems to have a simple sample showing how to use that class to get the CPU usage: using PerformanceCounter Class to retrieve cp and memory usage

ho1
That is an excellent idea.. I never thought of other ways. Though this wouldn't be good for my system because I'm monitoring everything else using WMI. Using performance counters for two properties and WMI for the others makes the code dirty.... but at least it works :)
Raze2dust