455 pts.
 How to capture CPU utilization efficiently in various Unix m/c’s?
We need to capture CPU utilization while load run of our testing in different environments (solaris, Linux, AIX) with single or multi cpu's. In Solaris, presently we are capturing CPU utlization using prstat. In Linux there are many commands like vmstat, mpstat, top, sar etc. Which is the best and reliable command?

Software/Hardware used:
ASKED: November 21, 2008  2:44 PM
UPDATED: December 1, 2008  3:59 PM

Answer Wiki:
Let me be specific in the above question. I need capture CPU utlization for a <b>process</b> in various env's.
Last Wiki Answer Submitted:  November 21, 2008  3:32 pm  by  Saimadhu   455 pts.
All Answer Wiki Contributors:  Saimadhu   455 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

On linux, we use “top”, and it has been very useful and reliable, And for Solaris, we use prstat too.
Regards,

 63,535 pts.

 

In linux, i used the followin command for CPU utilization.
ps -eo pid,pcpu,args |grep <process name>

But many people think that this will not give correct CPU utilization. Any reason for this ?

 455 pts.

 

I think that is because the CPU usage from ps is not the “current” CPU usage, but an average.

This is from an Ubuntu man page:

CPU usage is currently expressed as the percentage of time spent running
during the entire lifetime of a process. This is not ideal, and it does not
conform to the standards that ps otherwise conforms to. CPU usage is unlikely
to add up to exactly 100%.

and this from other linux man page:

%CPU shows the cputime/realtime percentage. It will not add up to 100% unless you are lucky. It is time used divided by the time the process has been running.

 63,535 pts.

 

In Intel Core Duo, the percentage of CPU utilization by top command shown as more than 100% (200%, etc). Why?

 455 pts.

 

I think it is because it sees the core duo as if it has two processors.
How does it show CPU usage if you turn off the “single cpu” mode, by pressing the “1″ key ?

 63,535 pts.