Topic: System Load and Process Monitoring
The father of all process monitoring tools must be ps. In the beginning, there was only ps and it is still the definitive tool for monitoring processes. The name is an acronym for "Process Status" as it is used to check on your own processes, or those of others using the same system
The current version of ps supports a staggering number of options in a bewildering array of styles. Typically, I use three or four options at most. Note that ps prefers BSD-style options, specified without the leading dash you may be used to.
By default ps show basic information about your own processes:
$ ps
PID TTY TIME CMD
19535 pts/0 00:00:00 bash
19550 pts/0 00:00:00 ps
With the addition of the u option, you'll get more information about each process. This is called the user-oriented output style:
$ ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
kgirrard 19535 0.0 0.2 1728 968 pts/0 S 08:29 0:00 -bash
kgirrard 19551 0.0 0.2 2504 880 pts/0 R 08:30 0:00 ps u
If you want to see information on processes other than just your own, add the x option:
$ ps ux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
dleeling 18483 0.0 0.2 1728 968 pts/1 S 08:21 0:00 -bash
kgirrard 19535 0.0 0.2 1728 968 pts/0 S 08:29 0:00 -bash
kgirrard 19579 0.0 0.2 2504 880 pts/0 R 08:33 0:00 ps ux
Many processes aren't associated with users at terminals. To show these, which include most of those that provide network services, add the a option too:
$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 1096 472 ? S Jun26 0:03 init [3]
root 2 0.0 0.0 0 0 ? SW Jun26 0:00 [kflushd]
root 3 0.0 0.0 0 0 ? SW Jun26 0:00 [kpiod]
root 4 0.0 0.0 0 0 ? SW Jun26 0:00 [kswapd]
root 5 0.0 0.0 0 0 ? SW< Jun26 0:00 [mdrecoveryd]
bin 316 0.0 0.0 1088 368 ? S Jun26 0:00 portmap
root 351 0.0 0.1 1132 412 ? S Jun26 0:00 /sbin/apcupsd
root 412 0.0 0.1 1284 532 ? S Jun26 0:00 crond
root 430 0.0 0.1 1240 516 ? S Jun26 0:01 inetd
root 444 0.0 0.5 3084 2008 ? S Jun26 0:11 named
root 458 0.0 0.3 1324 1324 ? SL Jun26 0:00 xntpd
root 473 0.0 0.1 1288 516 ? S Jun26 0:00 lpd
root 491 0.0 0.1 1580 640 ? S Jun26 0:01 /usr/sbin/dhcpd
root 512 0.0 0.1 1884 716 ? S Jun26 0:01 sendmail
root 520 0.0 0.1 1856 752 ? S Jun26 0:00 /usr/sbin/httpd
root 557 0.0 0.1 3212 424 ? S Jun26 0:00 squid -D
...
(The complete list of processes generated by ps aux is quite long! You might want to use a pager such as more or less when looking at the full list of processes.)
There are a few pieces of information about each process that need some explanation, expecially the cyptic ones like the STAT column.
USER: The owner of the process, typically the user who started it
PID: The processes unique ID number. These are assigned sequentially as processes start. When they reach 30,000 or so, the number starts over again at 0. 0-5 are usually low-level operating system processes which never exit, however.
%CPU: Percentage of the CPU's time spent running this process.
%MEM: Percentage of total memory in use by this process
VSZ: Total virtual memory size, in 1K blocks.
RSS: Real Set Size, the actual amount of physical memory allocated to this process.
TTY: Terminal associated with this process. A ? indicates the process is not connected to a terminal.
STAT: Process state codes. Common states are S - Sleeping, R - Runnable (on run queue), N - Low priority task, Z - Zombie process
START: When the process was started, in hours and minutes, or a day if the process has been running for a while.
TIME: CPU time used by process since it started.
COMMAND: The command name. This can be modified by processes as they run, so don't rely on it abolutely!
The output from ps has many more options for different applications. Consult the manual page for complete information. Be forewarned that with three different methods to specify options, its a little overwhelming...
The Manual Page for ps
Back to UNIX Command of the Day
|