Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking for a way to output CPU usage percentage via the command line. I ran across this: wmic cpu get loadpercentage which gives me the desired percentage output however I want to test the CPU usage while running a certain command. Anyone have any idea? I tried doing it in a batch file but then realized that at the point i run wmic cpu get loadpercentage the CPU usage is no longer portraying the usage of the previous command. Ideally what I am looking for is something like this:

C:\> command xyz [ftp file.blah]

and then the file is uploaded correctly but the output is a percentage indicative of the CPU usage during the process. Not sure if I'm making myself clear. Hopefully something like this exists out there. Thanks in advance!

share|improve this question
    
What version of windows? XP/7? Server? Do you have access to powershell? –  AliGibbs Mar 28 '12 at 13:31
    
@AliGibbs Windows Server 2008 and Vista and yes I have access to powershell –  hanleyhansen Mar 28 '12 at 13:56

1 Answer 1

First of all, I knew about WMI - Windows Management Instrumentation - but I must admit I did NOT know about WMIC - WMI Command-Line :)

I have found the following blog post that I think helps here:

Rich's Blog - Get Process CPU Usage Using WMI
http://www.techish.net/2009/03/get-process-cpu-usage-using-wmi/

In that blog post, the author uses the Win32_PerfFormattedData_PerfProc_Process class to get the CPU usage of a process (in several ways).

For instance, if the name of the running process is "iexplore" (Internet Explorer) then you would run:

wmic path win32_perfformatteddata_perfproc_process where (Name=iexplore) get Name, Caption, PercentProcessorTime, IDProcess /format:list

Maybe you can do the following: have one open "Command Prompt" window where you run the "ftp command" and have another "Command Prompt" window where you run the wmic path win32_perfformatteddata_perfproc_processquery.

I hope this helps.

share|improve this answer
    
That would help but i need to do this 100s of times so it needs to be automated somehow. –  hanleyhansen Mar 28 '12 at 14:06
    
Very helpfull, Thank you very much. +10 for /format:list –  Nakka Chandra Jul 10 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.