Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to know the cpu utilization from a script [closed]

Tags:

Is there any command or possible way to know the cpu utilization in windows operating system for use on the command line or in a batch script?

like image 477
Bharath Avatar asked Mar 10 '10 07:03

Bharath


2 Answers

To determine the usage in general, you can use mcstellar and warren's answer. You also have the option of:

List all processes:

typeperf "\Process(*)\% Processor Time" -sc 1

List all processes, take 5 samples at 10 second intervals:

typeperf "\Process(*)\% Processor Time" -si 10 -sc 5

If you want a specific process, Rtvscan for example:

typeperf "\Process(Rtvscan)\% Processor Time" -si 10 -sc 5

I found it extremely useful to just monitor all process activity over a period of time. I could then dump it to a csv file and filter in a spreadsheet to remotely diagnose issues.

The following gives me 5 minutes (at 10 second intervals) of all processes. The data includes not just % Processor Time, but IO, memory, paging, etc.

typeperf -qx "\Process" > config.txt typeperf -cf config.txt -o perf.csv -f CSV -y -si 10 -sc 60

like image 109
Kimberly Avatar answered Nov 23 '22 16:11

Kimberly


To monitor at 1 second intervals use:

typeperf "\processor(_total)\% processor time" 

For only the current usage, use:

typeperf -sc 1 "\processor(_total)\% processor time" 
like image 36
mcstellar Avatar answered Nov 23 '22 15:11

mcstellar