Need CPU utilization of a machine

Hi Team,

I need to get the CPU utilization of a machine. I am using the following relevance:

unique values of (string values of selects "LoadPercentage from Win32_Processor" of wmi)

But the values returned by this relevance is different from the task manager data. is there any way to get the values of CPU utilization which is same as in the task manager ?

LoadPercentage is calculated every time you make the WMI call; it’s an average of the processor load over one second. Win32_Processor class - Win32 apps | Microsoft Learn

LoadPercentage
Data type: uint16
Access type: Read-only
Qualifiers: [Override][1] (“LoadPercentage”), [MappingStrings][1] (“Win32API|Performance Data”), [Units][1] (“percent”)
Load capacity of each processor, averaged to the last second. Processor loading refers to the total computing burden for each processor at one time.

In my testing, it takes almost exactly one second to return a value, every time; that appears to be because WMI starts a processor trace, then waits one second to provide the average load over that second.

q: unique values of (string values of selects "LoadPercentage from Win32_Processor" of wmi)
A: 8
T: 1016.063 ms

Task Manager appears to do the same thing - it updates once per second, showing the CPU load as an average load over that second.

The issue seems to be that Task Manager and BESClient don’t use the exact same slice of time to calculate the averages; so unless your CPU is under absolutely constant load (very unlikely), we’ll end up with two different values because we are using different slices of time to calculate the average loads.

Task Manager and BESClient will probably never give the exact same value, but neither value is wrong, they’re just averages.