[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Versions 3.2 and 4 Performance Tuning Guide

Using ps to Identify CPU-Intensive Programs

Three of the possible ps output columns report CPU use, each in a different way.

Column Value Is:
C Recently used CPU time for the process.
TIME Total CPU time used by the process since it started.
%CPU Total CPU time used by the process since it started divided by the elapsed time since the process started. This is a measure of the CPU dependence of the program.

The shell script:

$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:

  1. Flags that specify which processes are to be included in the output
  2. Flags that specify what information is to be displayed about each process

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:

PID Process ID.
TTY Terminal or pseudo-terminal associated with the process.
TIME Cumulative CPU time consumed, in minutes and seconds.
CMD Command the process is running.
USER Login name of the user to whom the process belongs.
UID Numeric user ID of the user to whom the process belongs.
PPID ID of this process's parent process.
C Recently used CPU time.
STIME Time the process started, if today. Otherwise the date the process started.
F Eight-character hexadecimal value describing the flags associated with the process (see the detailed description of the ps command).
S/STAT Status of the process (see the detailed description of the ps command).
PRI Current priority value of the process.
NI/NICE Nice value for the process.
ADDR Segment number of the process stack.
SZ/SIZE Number of working-segment pages that have been touched, times 4.
WCHAN Event on which the process is waiting.
RSS Sum of the numbers of working-segment and code-segment pages in memory, times 4.
SSIZ Size of the kernel stack.
%CPU Percentage of time since the process started that it was using the CPU.
%MEM RSS value divided by the machine size in KB, times 100, rounded to the nearest full percentage point.
PGIN Number of page-ins caused by page faults. Since all AIX I/O is classified as page faults, this is basically a measure of I/O volume.
LIM Limit on RSS size. Displayed as "xx" if not set.
TSIZ Size of the text section of the executable file.
TRS Number of code-segment pages, times 4.
environment Value of all the environment variables for the process.

[ Previous | Next | Contents | Glossary | Home | Search ]