Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top