Three of the possible ps output columns report CPU use, each in a different way.
$ps -ef | egrep -v "STIME|$LOGNAME" | sort +3 -r | head -n 15
is a tool for focusing on the most CPU-intensive user processes in the system. If we had used that script in the situation described in "Using vmstat to Monitor CPU Use", its output would have appeared as follows (the header line has been reinserted for clarity):
USER PID PPID C STIME TTY TIME CMD waters 45742 54701 120 15:19:05 pts/29 0:02 ./looper root 52121 1 11 15:32:33 pts/31 58:39 xhogger root 4250 1 3 15:32:33 pts/31 26:03 xmconsole allcon root 38812 4250 1 15:32:34 pts/31 8:58 xmconstats 0 3 30 root 27036 6864 1 15:18:35 - 0:00 rlogind root 47418 25925 0 17:04:26 - 0:00 coelogin <d29dbms:0> bick 37651 43538 0 16:58:40 pts/4 0:00 /bin/ksh bick 43538 1 0 16:58:38 - 0:07 aixterm luc 60061 27036 0 15:18:35 pts/18 0:00 -ksh
Recent CPU use is the fourth column ("C"). The looping program's process easily heads the list. Observe that the C value may understate the looping process's CPU usage, since the scheduler stops counting at 120.
The ps command is a very flexible tool for identifying the programs that are running in the system and the resources they are using. The individual options and columns are described in the formal documentation of ps in the AIX Version 4.3 Commands Reference.
Most of the flags of ps belong to one of two groups:
The following two tables are intended to simplify the task of choosing ps flags by summarizing the effects of the flags. In each table, the flags specified with a minus sign are on the left side of the table; the flags specified without a minus sign are on the right side. You cannot mix types. If the first flag is specified with a minus sign, all other flags in that ps command must be from the minus-sign group.
Process-Specifying Flags: | |||||||||||||
-G | -U | ||||||||||||
Process Listed Are: | -A | -a | -d | -e | -g | -k | -p | -t | -u | a | g | t | x |
All processes | Y | - | - | - | - | - | - | - | - | - | Y | - | - |
Not process group leaders and not associated with a terminal | - | Y | - | - | - | - | - | - | - | - | - | - | - |
Not process group leaders | - | - | Y | - | - | - | - | - | - | - | - | - | - |
Not kernel processes | - | - | - | Y | - | - | - | - | - | - | - | - | - |
Members of specified processgroups | - | - | - | - | Y | - | - | - | - | - | - | - | - |
Kernel processes | - | - | - | - | - | Y | - | - | - | - | - | - | - |
Those specified in process number list | - | - | - | - | - | - | Y | - | - | - | - | - | - |
Those associated with TTY(s) in the list | - | - | - | - | - | - | - Y (n TTYs) | - | - - (1 TTY) | Y | - | ||
Specified user's processes | - | - | - | - | - | - | - | - | Y | - | - | - | - |
Processes with terminals | - | - | - | - | - | - | - | - | - | Y | - | - | - |
Not associated with a TTY | - | - | - | - | - | - | - | - | - | - | - | - | Y |
If the ps command is issued without a process-specifying flag, the processes owned by the user issuing the ps command are displayed.
Column-Selecting Flags: | ||||||||||
-U | ||||||||||
Column: | Default1 | -f | -l | -u | Default2 | e | l | s | u | v |
PID | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
TTY | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
TIME | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
CMD | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
USER | - | Y | - | - | - | - | - | - | Y | - |
UID | - | - | Y | Y | - | - | Y | - | - | - |
PPID | - | Y | Y | - | - | - | Y | - | - | - |
C | - | Y | Y | - | - | - | Y | - | - | - |
STIME | - | Y | - | - | - | - | - | - | Y | - |
F | - | - | Y | - | - | - | - | - | - | - |
S/STAT | - | - | Y | - | Y | Y | Y | Y | Y | Y |
PRI | - | - | Y | - | - | - | Y | - | - | - |
NI/NICE | - | - | Y | - | - | - | Y | - | - | - |
ADDR | - | - | Y | - | - | - | Y | - | - | - |
SZ/SIZE | - | - | Y | - | - | - | Y | - | Y | Y |
WCHAN | - | - | Y | - | - | - | Y | - | - | - |
RSS | - | - | - | - | - | - | Y | - | Y | Y |
SSIZ | - | - | - | - | - | - | - | Y | - | - |
%CPU | - | - | - | - | - | - | - | - | Y | Y |
%MEM | - | - | - | - | - | - | - | - | Y | Y |
PGIN | - | - | - | - | - | - | - | - | - | Y |
LIM | - | - | - | - | - | - | - | - | - | Y |
TSIZ | - | - | - | - | - | - | - | - | - | Y |
TRS | - | - | - | - | - | - | - | - | - | Y |
environment - (following the command; has no column heading) | - | - | - | - | Y | - | - | - | - |
If ps is given with no flags or with a process-specifying flag that begins with a minus sign, the columns displayed are those shown for Default1. If the command is given with a process-specifying flag that does not begin with minus, Default2 columns are displayed. The -u or -U flag is both a process-specifying and column-selecting flag.
The following are brief descriptions of the contents of the columns: