Process cpu % 
Author Message
 Process cpu %

I have seen this question asked a few times but never specifically
answered. How would you imitate the cpu % usage as in the NT task
manager (or the unix top command). I have output out all the fields for
processes in WMI and none of them talk about cpu %.

TIA
Michael Janos

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 17 May 2003 03:00:00 GMT  
 Process cpu %
set wmi = getobject("winmgmts:")
wql = "select * from win32_processor " _
    & "where deviceid='cpu0'"
set results = wmi.execquery(wql)
for each cpu in results
  msgbox cpu.loadpercentage
next

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> I have seen this question asked a few times but never specifically
> answered. How would you imitate the cpu % usage as in the NT task
> manager (or the unix top command). I have output out all the fields for
> processes in WMI and none of them talk about cpu %.

> TIA
> Michael Janos

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 17 May 2003 03:00:00 GMT  
 Process cpu %
Hi All,

 so far as I remember, I've never seen a real solution. The WMI process
times always use the cumulated time since the process has started. What
should, nearly, do the job is:
-    take the accurate time from WMI
-    take the process list without processing and preserve the collection
-    take the accurate time from WMI a second time
-    take the process list a second time
-    calculate the difference in time
-    build the sum for the overall process time of all processes
    (This step must build the common set of the two process lists !!![Some
are new, some died]
-    build the per cent value for each process

Sorry, I never found time to do it. It's no too complicated, but invokes a
lot of steps.....

Best regards,
Manfred Braun

(Private)
Lange Roetterstrasse 7
D68167 Mannheim
Germany


(Remove the anti-spam-underscore to mail me!)


Quote:
> set wmi = getobject("winmgmts:")
> wql = "select * from win32_processor " _
>     & "where deviceid='cpu0'"
> set results = wmi.execquery(wql)
> for each cpu in results
>   msgbox cpu.loadpercentage
> next

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --




- Show quoted text -

Quote:
> > I have seen this question asked a few times but never specifically
> > answered. How would you imitate the cpu % usage as in the NT task
> > manager (or the unix top command). I have output out all the fields for
> > processes in WMI and none of them talk about cpu %.

> > TIA
> > Michael Janos

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.



Sun, 18 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Process CPU Measurement???

2. WMI Process CPU load

3. WMI process cpu load

4. view processes & cpu

5. Retrieve the top 5 processes that uses most CPU time

6. Percentage CPU for a particular process

7. Percentage CPU for a particular process

8. Killing a process and all its children processes....

9. Obtaining process id of newly created process

10. Killing a process and all its children processes....

11. Win32_Process ( CPU Usage ) Issue

12. Determining CPU Speed of client

 

 
Powered by phpBB® Forum Software