Annotation of src/usr.bin/top/top.1, Revision 1.32
1.32 ! tedu 1: .\" $OpenBSD: top.1,v 1.31 2005/09/06 23:30:33 jmc Exp $
1.2 downsj 2: .\"
3: .\" Copyright (c) 1997, Jason Downs. All rights reserved.
4: .\"
5: .\" Redistribution and use in source and binary forms, with or without
6: .\" modification, are permitted provided that the following conditions
7: .\" are met:
8: .\" 1. Redistributions of source code must retain the above copyright
9: .\" notice, this list of conditions and the following disclaimer.
10: .\" 2. Redistributions in binary form must reproduce the above copyright
11: .\" notice, this list of conditions and the following disclaimer in the
12: .\" documentation and/or other materials provided with the distribution.
13: .\"
14: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
15: .\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17: .\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
18: .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19: .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20: .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21: .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24: .\" SUCH DAMAGE.
25: .\"
26: .Dd August 14, 1997
27: .Dt TOP 1
1.10 aaron 28: .Os
1.2 downsj 29: .Sh NAME
30: .Nm top
1.5 aaron 31: .Nd display and update information about the top CPU processes
1.2 downsj 32: .Sh SYNOPSIS
1.6 aaron 33: .Nm top
1.27 jmc 34: .Op Fl bIinqSu
1.2 downsj 35: .Op Fl d Ar count
1.23 jmc 36: .Op Fl o Ar field
1.25 otto 37: .Op Fl p Ar pid
1.2 downsj 38: .Op Fl s Ar time
39: .Op Fl U Ar username
40: .Op Ar number
41: .Sh DESCRIPTION
42: .Nm
43: displays the top processes on the system and periodically updates this
1.13 aaron 44: information.
45: If standard output is an intelligent terminal (see below) then
1.1 downsj 46: as many processes as will fit on the terminal screen are displayed
1.13 aaron 47: by default.
48: Otherwise, a good number of them are shown (around 20).
49: Raw CPU percentage is used to rank the processes.
50: If
1.2 downsj 51: .Ar number
1.1 downsj 52: is given, then the top
1.2 downsj 53: .Ar number
1.1 downsj 54: processes will be displayed instead of the default.
1.2 downsj 55: .Pp
56: .Nm
1.1 downsj 57: makes a distinction between terminals that support advanced capabilities
1.13 aaron 58: and those that do not.
59: This distinction affects the choice of defaults for certain options.
60: In the remainder of this document, an
1.2 downsj 61: .Em intelligent
62: terminal is one that supports cursor addressing, clear screen, and clear
1.13 aaron 63: to end of line.
64: Conversely, a
65: .Dq dumb
66: terminal is one that does not support such features.
67: If the output of
1.2 downsj 68: .Nm
1.1 downsj 69: is redirected to a file, it acts as if it were being run on a dumb
70: terminal.
1.12 aaron 71: .Pp
72: The options are as follows:
1.15 aaron 73: .Bl -tag -width Ds
1.2 downsj 74: .It Fl b
75: Use
76: .Em batch
1.13 aaron 77: mode.
78: In this mode, all input from the terminal is ignored.
79: Interrupt characters (such as
80: .Ql ^C
81: and
82: .Ql ^\e )
83: still have an effect.
1.1 downsj 84: This is the default on a dumb terminal, or when the output is not a terminal.
1.23 jmc 85: .It Fl d Ar count
86: Show only
87: .Ar count
88: displays, then exit.
89: A display is considered to be one update of the screen.
90: This option allows the user to select the number of displays
91: to be shown before
92: .Nm
93: automatically exits.
94: For intelligent terminals, no upper limit is set.
95: The default is 1 for dumb terminals.
1.27 jmc 96: .It Fl I
97: Do not display idle processes.
98: By default,
99: .Nm
100: displays both active and idle processes.
1.2 downsj 101: .It Fl i
102: Use
103: .Em interactive
1.13 aaron 104: mode.
105: In this mode, any input is immediately read for processing.
106: See the section on
1.2 downsj 107: .Sx INTERACTIVE MODE
1.13 aaron 108: for an explanation of which keys perform what functions.
109: After the command
1.2 downsj 110: is processed, the screen will immediately be updated, even if the command was
1.13 aaron 111: not understood.
112: This mode is the default when standard output is an intelligent terminal.
1.2 downsj 113: .It Fl n
1.10 aaron 114: Use
1.2 downsj 115: .Em non-interactive
1.13 aaron 116: mode.
117: This is identical to
1.2 downsj 118: .Em batch
1.1 downsj 119: mode.
1.23 jmc 120: .It Fl o Ar field
121: Sort the process display area using the specified field as the primary key.
122: The field name is the name of the column as seen in the output,
123: but in lower case.
124: The
125: .Ox
1.26 jaredy 126: version of
127: .Nm
128: supports
1.23 jmc 129: .Ar cpu ,
130: .Ar size ,
131: .Ar res ,
132: .Ar time ,
133: and
134: .Ar pri .
1.25 otto 135: .It Fl p Ar pid
136: Show only the process
137: .Ar pid .
1.2 downsj 138: .It Fl q
1.1 downsj 139: Renice
1.2 downsj 140: .Nm
1.26 jaredy 141: to \-20 so that it will run faster.
1.13 aaron 142: This can be used when the system is
1.1 downsj 143: being very sluggish to improve the possibility of discovering the problem.
144: This option can only be used by root.
1.27 jmc 145: .It Fl S
146: Show system processes in the display.
147: Normally, system processes such as the pager and the swapper are not shown.
148: This option makes them visible.
1.23 jmc 149: .It Fl s Ar time
150: Set the delay between screen updates to
151: .Ar time
152: seconds.
153: The value may be fractional, to permit delays of less than 1 second.
154: The default delay between updates is 5 seconds.
1.32 ! tedu 155: .It Fl T
! 156: Show process threads in the display.
! 157: Normally, only the main process is shown.
! 158: This option makes all threads visible.
1.27 jmc 159: .It Fl U Ar username
160: Show only those processes owned by
161: .Ar username .
162: This option currently only accepts usernames and will not understand
163: UID numbers.
1.2 downsj 164: .It Fl u
1.13 aaron 165: Do not take the time to map UID numbers to usernames.
166: Normally,
1.2 downsj 167: .Nm
168: will read as much of the password database as is necessary to map
1.13 aaron 169: all the user ID numbers it encounters into login names.
170: This option
171: disables all that, while possibly decreasing execution time.
172: The UID numbers are displayed instead of the names.
1.2 downsj 173: .El
174: .Pp
1.1 downsj 175: Both
1.2 downsj 176: .Ar count
1.1 downsj 177: and
1.2 downsj 178: .Ar number
179: fields can be specified as
180: .Li infinite ,
1.13 aaron 181: indicating that they can stretch as far as possible.
182: This is accomplished by using any proper prefix of the keywords
1.2 downsj 183: .Li infinity ,
184: .Li maximum ,
1.1 downsj 185: or
1.2 downsj 186: .Li all .
1.1 downsj 187: The default for
1.2 downsj 188: .Ar count
1.1 downsj 189: on an intelligent terminal is, in fact,
1.2 downsj 190: .Li infinity .
191: .Pp
1.1 downsj 192: The environment variable
1.2 downsj 193: .Ev TOP
1.13 aaron 194: is examined for options before the command line is scanned.
195: This enables a user to set his or her own defaults.
196: The number of processes to display
1.1 downsj 197: can also be specified in the environment variable
1.2 downsj 198: .Ev TOP .
199: .Pp
1.1 downsj 200: The options
1.2 downsj 201: .Fl I ,
202: .Fl S ,
1.1 downsj 203: and
1.2 downsj 204: .Fl u
1.13 aaron 205: are actually toggles.
206: A second specification of any of these options
207: will negate the first.
208: Thus a user who has the environment variable
1.2 downsj 209: .Ev TOP
1.10 aaron 210: set to
1.5 aaron 211: .Dq -I
1.10 aaron 212: may use the command
1.5 aaron 213: .Dq top -I
1.2 downsj 214: to see idle processes.
215: .Sh INTERACTIVE MODE
1.1 downsj 216: When
1.2 downsj 217: .Nm
218: is running in
219: .Em interactive mode ,
1.13 aaron 220: it reads commands from the terminal and acts upon them accordingly.
221: In this mode, the terminal is put in
1.2 downsj 222: .Dv CBREAK ,
1.13 aaron 223: so that a character will be processed as soon as it is typed.
224: Almost always, a key will be pressed when
1.2 downsj 225: .Nm
1.1 downsj 226: is between displays; that is, while it is waiting for
1.2 downsj 227: .Ar time
1.13 aaron 228: seconds to elapse.
229: If this is the case, the command will be
1.1 downsj 230: processed and the display will be updated immediately thereafter
1.13 aaron 231: (reflecting any changes that the command may have specified).
232: This happens even if the command was incorrect.
233: If a key is pressed while
1.2 downsj 234: .Nm
1.1 downsj 235: is in the middle of updating the display, it will finish the update and
1.13 aaron 236: then process the command.
237: Some commands require additional information,
238: and the user will be prompted accordingly.
239: While typing this information
1.1 downsj 240: in, the user's erase and kill keys (as set up by the command
1.2 downsj 241: .Xr stty 1 )
1.1 downsj 242: are recognized, and a newline terminates the input.
1.2 downsj 243: .Pp
1.1 downsj 244: These commands are currently recognized (^L refers to control-L):
1.2 downsj 245: .Bl -tag -width XxXXXX
1.27 jmc 246: .It h or \&?
247: Display a summary of the commands (help screen).
1.2 downsj 248: .It ^L
1.1 downsj 249: Redraw the screen.
1.2 downsj 250: .It q
1.1 downsj 251: Quit
1.2 downsj 252: .Nm top .
1.23 jmc 253: .El
254: .Pp
255: The following commands may not be available with overstrike terminals:
256: .Bl -tag -width XxXXXX
1.29 markus 257: .It C
258: Toggle the display of process command line arguments.
1.2 downsj 259: .It d
1.1 downsj 260: Change the number of displays to show (prompt for new number).
261: Remember that the next display counts as one, so typing
1.5 aaron 262: .Dq d1
1.1 downsj 263: will make
1.2 downsj 264: .Nm
1.1 downsj 265: show one final display and then immediately exit.
1.23 jmc 266: .It e
267: Display a list of system errors (if any) generated by the last
268: .Li kill
269: or
270: .Li renice
271: command.
1.27 jmc 272: .It I or i
1.23 jmc 273: Toggle the display of idle processes.
1.2 downsj 274: .It k
275: Send a signal
1.21 jmc 276: .Pf ( Dv TERM
1.13 aaron 277: by default) to a list of processes.
278: This acts similarly to the command
1.2 downsj 279: .Xr kill 1 .
1.23 jmc 280: .It n or #
281: Change the number of processes to display (prompt for new number).
282: .It o
283: Change the sorting order of the processes
284: .Pq prompt for order .
285: Values are the same as for the
286: .Fl o
287: flag, as detailed above.
1.25 otto 288: .It p
1.26 jaredy 289: Display a specific process (prompt for PID).
290: If the PID specified is simply
1.25 otto 291: .Dq + ,
292: then processes belonging to all users will be displayed.
1.2 downsj 293: .It r
294: Change the priority (the
295: .Em nice )
1.26 jaredy 296: of a list of processes (prompt for the new nice value and the list of
297: PIDs, all separated by space).
1.13 aaron 298: This acts similarly to the command
1.2 downsj 299: .Xr renice 8 .
1.27 jmc 300: .It S
301: Toggle the display of system processes.
1.23 jmc 302: .It s
303: Change the number of seconds to delay between displays
304: (prompt for new number).
1.2 downsj 305: .It u
1.1 downsj 306: Display only processes owned by a specific username (prompt for username).
1.2 downsj 307: If the username specified is simply
308: .Dq + ,
309: then processes belonging to all users will be displayed.
310: .El
311: .Sh THE DISPLAY
312: .\" The actual display varies depending on the specific variant of Unix
313: .\" that the machine is running. This description may not exactly match
314: .\" what is seen by top running on this particular machine. Differences
315: .\" are listed at the end of this manual entry.
316: .\" .Pp
1.1 downsj 317: The top few lines of the display show general information
318: about the state of the system, including
1.11 millert 319: .\" the last process ID assigned to a process,
1.2 downsj 320: .\" (on most systems),
1.24 millert 321: the three load average numbers,
1.1 downsj 322: the current time,
323: the number of existing processes,
324: the number of processes in each state
1.26 jaredy 325: (starting, running, idle, stopped, zombie, dead, and on processor),
1.1 downsj 326: and a percentage of time spent in each of the processor states
1.26 jaredy 327: (user, nice, system, interrupt, and idle).
1.17 aaron 328: It also includes information about physical and virtual memory allocation.
1.24 millert 329: The load average numbers give the number of jobs in the run queue averaged
1.26 jaredy 330: over 1, 5, and 15 minutes.
1.2 downsj 331: .Pp
1.1 downsj 332: The remainder of the screen displays information about individual
1.13 aaron 333: processes.
334: This display is similar in spirit to
1.2 downsj 335: .Xr ps 1
1.13 aaron 336: but it is not exactly the same.
1.26 jaredy 337: The following fields are displayed:
338: .Bl -tag -width USERNAME -offset indent
339: .It PID
340: The process ID.
341: .It USERNAME
342: The name of the process's owner.
343: .It UID
344: Used instead of USERNAME if
1.2 downsj 345: .Fl u
1.26 jaredy 346: is specified.
347: .It PRI
348: The current priority of the process.
349: .It NICE
350: The nice amount (in the range \-20 to 20).
351: .It SIZE
352: The total size of the process (the text, data, and stack segments).
353: .It RES
354: The current amount of resident memory.
355: .It STATE
356: The current state (one of
357: .Li start ,
358: .Li run ,
1.2 downsj 359: .Li sleep ,
1.26 jaredy 360: .Li stop ,
361: .Li idle ,
1.2 downsj 362: .Li zomb ,
1.26 jaredy 363: .Li dead ,
1.2 downsj 364: or
1.26 jaredy 365: .Li onproc ) .
366: On multi-processor systems, this is followed by a slash and the CPU
367: number on which the process is bound.
368: .It WAIT
369: A description of the wait channel the process is sleeping on if it's
370: asleep.
371: .It TIME
372: The number of system and user CPU seconds that the process has used.
373: .It CPU
374: The raw percentage of CPU usage and the default field on which the
375: display is sorted.
376: .It COMMAND
377: The name of the command that the process is currently running.
378: (If the process is swapped out, this column is enclosed by angle
379: brackets.)
380: .El
1.2 downsj 381: .Sh ENVIRONMENT
1.26 jaredy 382: .Bl -tag -width Ev
1.2 downsj 383: .It Ev TOP
384: User-configurable defaults for options.
385: .El
386: .Sh FILES
1.26 jaredy 387: .Bl -tag -width Pa -compact
1.2 downsj 388: .It Pa /dev/kmem
389: kernel memory
390: .It Pa /dev/mem
391: physical memory
1.26 jaredy 392: .It Pa /etc/passwd
393: used to map user ID to name
1.2 downsj 394: .It Pa /bsd
395: kernel image
1.14 aaron 396: .El
1.13 aaron 397: .Sh SEE ALSO
1.30 jmc 398: .Xr fstat 1 ,
1.13 aaron 399: .Xr kill 1 ,
1.30 jmc 400: .Xr netstat 1 ,
1.13 aaron 401: .Xr ps 1 ,
402: .Xr stty 1 ,
403: .Xr systat 1 ,
404: .Xr mem 4 ,
1.30 jmc 405: .Xr iostat 8 ,
406: .Xr pstat 8 ,
407: .Xr renice 8 ,
1.31 jmc 408: .Xr vmstat 8
1.16 aaron 409: .Sh AUTHORS
410: William LeFebvre, EECS Department, Northwestern University
1.2 downsj 411: .Sh BUGS
1.1 downsj 412: As with
1.2 downsj 413: .Xr ps 1 ,
1.1 downsj 414: things can change while
1.2 downsj 415: .Nm
1.13 aaron 416: is collecting information for an update.
417: The picture it gives is only a
1.1 downsj 418: close approximation to reality.