Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: Win32_PerfFormattedData_PerfOS_Processor

HTVi
TV Discussion Newsgroups

Win32_PerfFormattedData_PerfOS_Processor
bobrivers.br[ at ]gmail.com 6/18/2007 5:49:14 PM
Hi,

I'm trying to use WMI to calculate cpu usage. I'm running the
following script into a W2K3 box. It works fine, but I had some doubts
about the values that I receive.

Reading MSDN (http://msdn2.microsoft.com/En-US/library/aa394271.aspx),
it tells that PercentProcessorTime "This property was designed as a
primary indicator of processor activity". Ok, but I want to break it
into user time and system time.

So, I think that I must use PercentUserTime, PercentPrivilegedTime and
PercentIdleTime. If I sum this 3 values, I should get 100%.

The problem is that almost never the sum is equals to 100. I
understand that we can have some round problems. But I was expecting
to see 99, 100 or 101. When the server is busy, often I receive 103.
If it isn't so busy, sometimes I receive 98...

Am I being grumpy?


Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_PerfFormattedData_PerfOS_Processor WHERE name='_Total'", "WQL",
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
WScript.Echo "PercentIdleTime: " & objItem.PercentIdleTime
WScript.Echo "PercentInterruptTime: " &
objItem.PercentInterruptTime
WScript.Echo "PercentPrivilegedTime: " &
objItem.PercentPrivilegedTime
WScript.Echo "PercentProcessorTime: " &
objItem.PercentProcessorTime
WScript.Echo "PercentUserTime: " & objItem.PercentUserTime
Next

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen