hankknight
asked on
Linux: get wcpu from top
top -bn 1
This returns %CPU usage for each process. How can I get the %WCPU usage instead?
You probably can't, without changing the code within "top". I've only come across WCPU in the HPUX version of "top".
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ps -eo "%c %C"
This returns:
COMMAND %CPU
php 10.0
sftp-server 5.0
ps 3.0
bash 1.0
Are you sure that is wcpu and not cpu?
php 10.0
sftp-server 5.0
ps 3.0
bash 1.0
Hmm, not sure it is either, really. The man page says that %cpu is the total CPU time for the process since it started, divided by the time the process has been running. This is different from the "top" values of %CPU (the time that a process is using the CPU in a particular period, e.g. 10 seconds, divided by that period) and %WCPU (as %CPU, but weighted by some method which I can't find described clearly).
All are approximations to some extent - is there a reason why you particularly wanted WCPU?
All are approximations to some extent - is there a reason why you particularly wanted WCPU?
ASKER
I want weighted CPU because it seems to give a better indication of processes that are have high CPU usage for longer than a very short burst.
The values returned by your code seem to correspond to WCPU values anyway, so that is good.
Thanks!
The values returned by your code seem to correspond to WCPU values anyway, so that is good.
Thanks!