We noticed a significant different between the "percentage CPU" reported by TOP for a process (a Java instance of Tomcat) and that reported by issuing "ps -o pid,pcpu <process-id>". TOP indicated that the process was using 99% CPU, but "ps" just showed it using 40%. I have google and googled, read the man/info pages - but cannot find any explanation for how they each arrive at their figures. Any ideas or explanations are appreciated/welcome. Thanks - Richard
We noticed a significant different between the "percentage CPU" reported by TOP for a process (a Java instance of Tomcat) and that reported by issuing "ps -o pid,pcpu <process-id>". TOP indicated that the process was using 99% CPU, but "ps" just showed it using 40%.
I have google and googled, read the man/info pages - but cannot find any explanation for how they each arrive at their figures.
Any ideas or explanations are appreciated/welcome.
On Wednesday 24 August 2005 1:38 am, Richard Mixon (qwest) wrote:
the top(1) command uses a sample and measures the percentage of elapsed CPU
time between samples. PS is a single sample where percentage of CPU time is
expressed in a ratio between "CPU time used divided by the
time the process has been running".
--
Jerry Feldman
Jerry Feldman mailto:gaf@blu.org scribbled on Wednesday, August 24, 2005 5:55 AM:
We noticed a significant different between the "percentage CPU" reported by TOP for a process (a Java instance of Tomcat) and that reported by issuing "ps -o pid,pcpu <process-id>". TOP indicated that the process was using 99% CPU, but "ps" just showed it using 40%.
I have google and googled, read the man/info pages - but cannot find any explanation for how they each arrive at their figures.
Any ideas or explanations are appreciated/welcome.
On Wednesday 24 August 2005 1:38 am, Richard Mixon (qwest) wrote: the top(1) command uses a sample and measures the percentage of elapsed CPU time between samples. PS is a single sample where percentage of CPU time is expressed in a ratio between "CPU time used divided by the time the process has been running".
Jerry, thanks - this sounds good. But if top is time averaging cpu usage, I would expect it to report a lower percentage cpu usage than ps does.We are seeing the opposite. BTW, this is a dual Xeon with hyperthreading turned on. Any other ideas? Thanks - Richard
Richard Mixon (qwest) wrote:
Jerry Feldman mailto:gaf@blu.org scribbled on Wednesday, August 24, 2005 5:55 AM:
On Wednesday 24 August 2005 1:38 am, Richard Mixon (qwest) wrote:
We noticed a significant different between the "percentage CPU" reported by TOP for a process (a Java instance of Tomcat) and that reported by issuing "ps -o pid,pcpu <process-id>". TOP indicated that the process was using 99% CPU, but "ps" just showed it using 40%.
I have google and googled, read the man/info pages - but cannot find any explanation for how they each arrive at their figures.
Any ideas or explanations are appreciated/welcome.
the top(1) command uses a sample and measures the percentage of elapsed CPU time between samples. PS is a single sample where percentage of CPU time is expressed in a ratio between "CPU time used divided by the time the process has been running".
Jerry, thanks - this sounds good. But if top is time averaging cpu usage, I would expect it to report a lower percentage cpu usage than ps does.We are seeing the opposite. BTW, this is a dual Xeon with hyperthreading turned on.
Any other ideas?
Interesting question. I just started this: perl -e '{while(1){}}' & on a pretty idle dual Xeon running SuSE 9.2. Top shows me Cpu(s): 25.0% us, 0.0% sy, 0.0% ni, 74.5% id, 0.5% wa, 0.0% hi, 0.0% si 1550 root 25 0 8872 1400 8220 R 99.9 0.1 6:01.36 perl and I can use '1' to see the indivual HT that is running the process. ps on the other hand shows this: suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 8.8 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 9.2 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 9.6 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 10.0 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 14.1 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 30.1 So it looks to me that ps is doing some kind of long-term averaging. BTW, the same test on a single P4 running SuSE 9.3 says: dhoworth@cpepc210-3:/tmp/Perl-Tidy-20031021> ps -o pid,pcpu 22111 PID %CPU 22111 108 from the get go. So who knows what's going on! top gets my vote for being the truthful one. Better get back to my real work now ... Cheers, Dave
Dave Howorth mailto:dhoworth@mrc-lmb.cam.ac.uk scribbled on Wednesday, August 24, 2005 7:50 AM:
Richard Mixon (qwest) wrote:
Jerry Feldman mailto:gaf@blu.org scribbled on Wednesday, August 24, 2005 5:55 AM:
On Wednesday 24 August 2005 1:38 am, Richard Mixon (qwest) wrote:
We noticed a significant different between the "percentage CPU" reported by TOP for a process (a Java instance of Tomcat) and that reported by issuing "ps -o pid,pcpu <process-id>". TOP indicated that the process was using 99% CPU, but "ps" just showed it using 40%.
I have google and googled, read the man/info pages - but cannot find any explanation for how they each arrive at their figures.
Any ideas or explanations are appreciated/welcome.
the top(1) command uses a sample and measures the percentage of elapsed CPU time between samples. PS is a single sample where percentage of CPU time is expressed in a ratio between "CPU time used divided by the time the process has been running".
Jerry, thanks - this sounds good. But if top is time averaging cpu usage, I would expect it to report a lower percentage cpu usage than ps does.We are seeing the opposite. BTW, this is a dual Xeon with hyperthreading turned on.
Any other ideas?
Interesting question. I just started this: perl -e '{while(1){}}' & on a pretty idle dual Xeon running SuSE 9.2. Top shows me
Cpu(s): 25.0% us, 0.0% sy, 0.0% ni, 74.5% id, 0.5% wa, 0.0% hi, 0.0% si
1550 root 25 0 8872 1400 8220 R 99.9 0.1 6:01.36 perl
and I can use '1' to see the indivual HT that is running the process.
ps on the other hand shows this:
suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 8.8 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 9.2 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 9.6 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 10.0 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 14.1 suse1:~ # ps -o pid,pcpu 1550 PID %CPU 1550 30.1
So it looks to me that ps is doing some kind of long-term averaging.
BTW, the same test on a single P4 running SuSE 9.3 says:
dhoworth@cpepc210-3:/tmp/Perl-Tidy-20031021> ps -o pid,pcpu 22111 PID %CPU 22111 108
from the get go. So who knows what's going on! top gets my vote for being the truthful one.
Better get back to my real work now ...
Dave - thanks for the test and associated insight. Hmm - we had wanted to have a script use ps to tell us if a particular java process started maxing out the cpu. Can't do that with top, so need to think about this more - or else get a real monitoring framework like nagios. Thanks again - Richard
On Wednesday 24 August 2005 10:15 am, Richard Mixon (qwest) wrote:
Jerry, thanks - this sounds good. But if top is time averaging cpu usage, I would expect it to report a lower percentage cpu usage than ps does.We are seeing the opposite. BTW, this is a dual Xeon with hyperthreading turned on. Top is not time averaging. it is giving you a percentage of CPU of the elapsed CPU time since the last screen update as a percentage of total CPU time. I think that the figures may be skewed as a result of the hyperthreading. Note that the I global command toggles between Irix and Solaris mode, and should give you a different result. -- Jerry Feldman
Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
Jerry Feldman mailto:gaf@blu.org scribbled on Wednesday, August 24, 2005 8:57 AM:
On Wednesday 24 August 2005 10:15 am, Richard Mixon (qwest) wrote:
Jerry, thanks - this sounds good. But if top is time averaging cpu usage, I would expect it to report a lower percentage cpu usage than ps does.We are seeing the opposite. BTW, this is a dual Xeon with hyperthreading turned on.
Top is not time averaging. it is giving you a percentage of CPU of the elapsed CPU time since the last screen update as a percentage of total CPU time. I think that the figures may be skewed as a result of the hyperthreading. Note that the I global command toggles between Irix and Solaris mode, and should give you a different result. --
Jerry, thanks once again - more understanding is good.
On Wednesday, August 24, 2005 @ 6:16 AM, Richard Mixon wrote:
Jerry Feldman mailto:gaf@blu.org scribbled on Wednesday, August 24, 2005 5:55 AM:
We noticed a significant different between the "percentage CPU" reported by TOP for a process (a Java instance of Tomcat) and that reported by issuing "ps -o pid,pcpu <process-id>". TOP indicated that the process was using 99% CPU, but "ps" just showed it using 40%.
I have google and googled, read the man/info pages - but cannot find any explanation for how they each arrive at their figures.
Any ideas or explanations are appreciated/welcome.
On Wednesday 24 August 2005 1:38 am, Richard Mixon (qwest) wrote: the top(1) command uses a sample and measures the percentage of elapsed CPU time between samples. PS is a single sample where percentage of CPU time is expressed in a ratio between "CPU time used divided by the time the process has been running".
Jerry, thanks - this sounds good. But if top is time averaging cpu usage, I would expect it to report a lower percentage cpu usage than ps does.We are seeing the opposite. BTW, this is a dual Xeon with hyperthreading turned on.
Any other ideas?
Thanks - Richard
ps could be lower if that process had just started. I. e., it could be a heavy load now, but not as related to your total usage for the session (right?). Greg Wallace
Greg Wallace mailto:jgregw@acsalaska.net scribbled on Wednesday, August 24, 2005 9:23 PM:
On Wednesday, August 24, 2005 @ 6:16 AM, Richard Mixon wrote:
Jerry Feldman mailto:gaf@blu.org scribbled on Wednesday, August 24, 2005 5:55 AM:
We noticed a significant different between the "percentage CPU" reported by TOP for a process (a Java instance of Tomcat) and that reported by issuing "ps -o pid,pcpu <process-id>". TOP indicated that the process was using 99% CPU, but "ps" just showed it using 40%.
I have google and googled, read the man/info pages - but cannot find any explanation for how they each arrive at their figures.
Any ideas or explanations are appreciated/welcome.
On Wednesday 24 August 2005 1:38 am, Richard Mixon (qwest) wrote: the top(1) command uses a sample and measures the percentage of elapsed CPU time between samples. PS is a single sample where percentage of CPU time is expressed in a ratio between "CPU time used divided by the time the process has been running".
Jerry, thanks - this sounds good. But if top is time averaging cpu usage, I would expect it to report a lower percentage cpu usage than ps does.We are seeing the opposite. BTW, this is a dual Xeon with hyperthreading turned on.
Any other ideas?
Thanks - Richard
ps could be lower if that process had just started. I. e., it could be a heavy load now, but not as related to your total usage for the session (right?).
Greg, good idea but unfortunately the process had been at 99% CPU usage in top for a number of minutes, but using ps it only showed 40%. - Richard
On Wed, Aug 24, 2005 at 09:57:14PM -0700, Richard Mixon (qwest) wrote:
Greg, good idea but unfortunately the process had been at 99% CPU usage in top for a number of minutes, but using ps it only showed 40%.
Did you try "H" option in ps command? I think the difference is because ps does not show thread info with default options. -Kastus
participants (5)
-
Dave Howorth
-
Greg Wallace
-
Jerry Feldman
-
Kastus
-
Richard Mixon (qwest)