Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Linux: get wcpu from top

top -bn 1

Open in new window

This returns %CPU usage for each process.  How can I get the %WCPU usage instead?
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hankknight

ASKER

 ps -eo  "%c %C"

Open in new window

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?
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?
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!