Annotation of src/usr.bin/top/top.1, Revision 1.46
1.46 ! otto 1: .\" $OpenBSD: top.1,v 1.45 2007/03/15 22:02:22 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.45 jmc 34: .Bk -words
1.34 otto 35: .Op Fl bCIinqSTu
1.2 downsj 36: .Op Fl d Ar count
1.45 jmc 37: .Op Fl g Ar string
1.23 jmc 38: .Op Fl o Ar field
1.25 otto 39: .Op Fl p Ar pid
1.2 downsj 40: .Op Fl s Ar time
1.45 jmc 41: .Op Fl U Ar user
1.2 downsj 42: .Op Ar number
1.45 jmc 43: .Ek
1.2 downsj 44: .Sh DESCRIPTION
45: .Nm
46: displays the top processes on the system and periodically updates this
1.13 aaron 47: information.
48: If standard output is an intelligent terminal (see below) then
1.1 downsj 49: as many processes as will fit on the terminal screen are displayed
1.13 aaron 50: by default.
51: Otherwise, a good number of them are shown (around 20).
52: Raw CPU percentage is used to rank the processes.
53: If
1.2 downsj 54: .Ar number
1.1 downsj 55: is given, then the top
1.2 downsj 56: .Ar number
1.1 downsj 57: processes will be displayed instead of the default.
1.2 downsj 58: .Pp
59: .Nm
1.1 downsj 60: makes a distinction between terminals that support advanced capabilities
1.13 aaron 61: and those that do not.
62: This distinction affects the choice of defaults for certain options.
63: In the remainder of this document, an
1.2 downsj 64: .Em intelligent
65: terminal is one that supports cursor addressing, clear screen, and clear
1.13 aaron 66: to end of line.
67: Conversely, a
1.43 jmc 68: .Em dumb
1.13 aaron 69: terminal is one that does not support such features.
70: If the output of
1.2 downsj 71: .Nm
1.1 downsj 72: is redirected to a file, it acts as if it were being run on a dumb
73: terminal.
1.12 aaron 74: .Pp
75: The options are as follows:
1.15 aaron 76: .Bl -tag -width Ds
1.2 downsj 77: .It Fl b
78: Use
79: .Em batch
1.13 aaron 80: mode.
81: In this mode, all input from the terminal is ignored.
82: Interrupt characters (such as
83: .Ql ^C
84: and
85: .Ql ^\e )
86: still have an effect.
1.1 downsj 87: This is the default on a dumb terminal, or when the output is not a terminal.
1.34 otto 88: .It Fl C
1.42 jmc 89: Show command line arguments
90: as well as the process itself.
1.23 jmc 91: .It Fl d Ar count
92: Show only
93: .Ar count
94: displays, then exit.
95: A display is considered to be one update of the screen.
96: This option allows the user to select the number of displays
97: to be shown before
98: .Nm
99: automatically exits.
100: For intelligent terminals, no upper limit is set.
101: The default is 1 for dumb terminals.
1.45 jmc 102: .It Fl g Ar string
103: Display only processes that contain
104: .Ar string
1.35 otto 105: in their command name.
1.27 jmc 106: .It Fl I
107: Do not display idle processes.
108: By default,
109: .Nm
110: displays both active and idle processes.
1.2 downsj 111: .It Fl i
112: Use
113: .Em interactive
1.13 aaron 114: mode.
115: In this mode, any input is immediately read for processing.
116: See the section on
1.2 downsj 117: .Sx INTERACTIVE MODE
1.13 aaron 118: for an explanation of which keys perform what functions.
119: After the command
1.2 downsj 120: is processed, the screen will immediately be updated, even if the command was
1.13 aaron 121: not understood.
122: This mode is the default when standard output is an intelligent terminal.
1.2 downsj 123: .It Fl n
1.10 aaron 124: Use
1.2 downsj 125: .Em non-interactive
1.13 aaron 126: mode.
127: This is identical to
1.2 downsj 128: .Em batch
1.1 downsj 129: mode.
1.23 jmc 130: .It Fl o Ar field
1.45 jmc 131: Sort the process display area using the specified
132: .Ar field
133: as the primary key.
1.23 jmc 134: The field name is the name of the column as seen in the output,
135: but in lower case.
136: The
137: .Ox
1.26 jaredy 138: version of
139: .Nm
140: supports
1.23 jmc 141: .Ar cpu ,
142: .Ar size ,
143: .Ar res ,
144: .Ar time ,
145: and
146: .Ar pri .
1.25 otto 147: .It Fl p Ar pid
148: Show only the process
149: .Ar pid .
1.2 downsj 150: .It Fl q
1.1 downsj 151: Renice
1.2 downsj 152: .Nm
1.26 jaredy 153: to \-20 so that it will run faster.
1.13 aaron 154: This can be used when the system is
1.1 downsj 155: being very sluggish to improve the possibility of discovering the problem.
156: This option can only be used by root.
1.27 jmc 157: .It Fl S
158: Show system processes in the display.
159: Normally, system processes such as the pager and the swapper are not shown.
160: This option makes them visible.
1.23 jmc 161: .It Fl s Ar time
162: Set the delay between screen updates to
163: .Ar time
164: seconds.
165: The value may be fractional, to permit delays of less than 1 second.
166: The default delay between updates is 5 seconds.
1.32 tedu 167: .It Fl T
168: Show process threads in the display.
169: Normally, only the main process is shown.
170: This option makes all threads visible.
1.45 jmc 171: .It Fl U Ar user
1.27 jmc 172: Show only those processes owned by
1.45 jmc 173: .Ar user .
1.27 jmc 174: This option currently only accepts usernames and will not understand
175: UID numbers.
1.2 downsj 176: .It Fl u
1.13 aaron 177: Do not take the time to map UID numbers to usernames.
178: Normally,
1.2 downsj 179: .Nm
180: will read as much of the password database as is necessary to map
1.13 aaron 181: all the user ID numbers it encounters into login names.
182: This option
183: disables all that, while possibly decreasing execution time.
184: The UID numbers are displayed instead of the names.
1.2 downsj 185: .El
186: .Pp
1.1 downsj 187: Both
1.2 downsj 188: .Ar count
1.1 downsj 189: and
1.2 downsj 190: .Ar number
191: fields can be specified as
192: .Li infinite ,
1.13 aaron 193: indicating that they can stretch as far as possible.
194: This is accomplished by using any proper prefix of the keywords
1.2 downsj 195: .Li infinity ,
196: .Li maximum ,
1.1 downsj 197: or
1.2 downsj 198: .Li all .
1.1 downsj 199: The default for
1.2 downsj 200: .Ar count
1.1 downsj 201: on an intelligent terminal is, in fact,
1.2 downsj 202: .Li infinity .
203: .Pp
1.1 downsj 204: The environment variable
1.2 downsj 205: .Ev TOP
1.13 aaron 206: is examined for options before the command line is scanned.
207: This enables a user to set his or her own defaults.
208: The number of processes to display
1.1 downsj 209: can also be specified in the environment variable
1.2 downsj 210: .Ev TOP .
211: .Pp
1.1 downsj 212: The options
1.2 downsj 213: .Fl I ,
214: .Fl S ,
1.1 downsj 215: and
1.2 downsj 216: .Fl u
1.13 aaron 217: are actually toggles.
218: A second specification of any of these options
219: will negate the first.
220: Thus a user who has the environment variable
1.2 downsj 221: .Ev TOP
1.10 aaron 222: set to
1.5 aaron 223: .Dq -I
1.10 aaron 224: may use the command
1.5 aaron 225: .Dq top -I
1.2 downsj 226: to see idle processes.
227: .Sh INTERACTIVE MODE
1.1 downsj 228: When
1.2 downsj 229: .Nm
230: is running in
231: .Em interactive mode ,
1.13 aaron 232: it reads commands from the terminal and acts upon them accordingly.
233: In this mode, the terminal is put in
1.2 downsj 234: .Dv CBREAK ,
1.13 aaron 235: so that a character will be processed as soon as it is typed.
236: Almost always, a key will be pressed when
1.2 downsj 237: .Nm
1.1 downsj 238: is between displays; that is, while it is waiting for
1.2 downsj 239: .Ar time
1.13 aaron 240: seconds to elapse.
241: If this is the case, the command will be
1.1 downsj 242: processed and the display will be updated immediately thereafter
1.13 aaron 243: (reflecting any changes that the command may have specified).
244: This happens even if the command was incorrect.
245: If a key is pressed while
1.2 downsj 246: .Nm
1.1 downsj 247: is in the middle of updating the display, it will finish the update and
1.13 aaron 248: then process the command.
249: Some commands require additional information,
250: and the user will be prompted accordingly.
251: While typing this information
1.1 downsj 252: in, the user's erase and kill keys (as set up by the command
1.2 downsj 253: .Xr stty 1 )
1.1 downsj 254: are recognized, and a newline terminates the input.
1.2 downsj 255: .Pp
1.1 downsj 256: These commands are currently recognized (^L refers to control-L):
1.2 downsj 257: .Bl -tag -width XxXXXX
1.40 jmc 258: .It h \*(Ba \&?
1.27 jmc 259: Display a summary of the commands (help screen).
1.2 downsj 260: .It ^L
1.1 downsj 261: Redraw the screen.
1.2 downsj 262: .It q
1.1 downsj 263: Quit
1.40 jmc 264: .Nm .
1.23 jmc 265: .El
266: .Bl -tag -width XxXXXX
1.38 otto 267: .It +
1.39 jmc 268: Reset any filters put in place by the
269: .Sq g ,
270: .Sq p ,
271: and
272: .Sq u
273: interactive commands,
274: or their command line equivalents.
1.29 markus 275: .It C
276: Toggle the display of process command line arguments.
1.44 jmc 277: .It d Ar count
278: Show only
279: .Ar count
280: displays,
281: then exit.
1.23 jmc 282: .It e
283: Display a list of system errors (if any) generated by the last
284: .Li kill
285: or
286: .Li renice
287: command.
1.40 jmc 288: .It g Ar string
289: Display only processes that contain
290: .Ar string
291: in their command name.
292: .Sq g+
293: shows all processes.
294: .It I \*(Ba i
1.23 jmc 295: Toggle the display of idle processes.
1.41 jmc 296: .It Xo k
297: .Op - Ns Ar sig
298: .Ar pid
299: .Xc
300: Send signal
301: .No - Ns Ar sig
1.21 jmc 302: .Pf ( Dv TERM
1.41 jmc 303: by default) to process
304: .Ar pid .
1.13 aaron 305: This acts similarly to the command
1.2 downsj 306: .Xr kill 1 .
1.44 jmc 307: .It n\*(Ba# Ar count
308: Show
309: .Ar count
1.40 jmc 310: processes.
311: .It o Ar field
1.45 jmc 312: Sort the process display area using the specified
313: .Ar field
314: as the primary key.
1.23 jmc 315: Values are the same as for the
316: .Fl o
317: flag, as detailed above.
1.46 ! otto 318: .It P Ar pid
! 319: Highlight a specific process, selected by
! 320: .Ar pid .
1.40 jmc 321: .It p Ar pid
1.45 jmc 322: Show only the process
1.40 jmc 323: .Ar pid .
324: .Sq p+
325: shows all processes.
1.44 jmc 326: .It r Ar count pid
1.2 downsj 327: Change the priority (the
328: .Em nice )
1.44 jmc 329: of a list of processes to
330: .Ar count
1.40 jmc 331: for process
332: .Ar pid .
1.13 aaron 333: This acts similarly to the command
1.2 downsj 334: .Xr renice 8 .
1.27 jmc 335: .It S
336: Toggle the display of system processes.
1.44 jmc 337: .It s Ar time
338: Set the delay between screen updates to
339: .Ar time
1.40 jmc 340: seconds.
1.36 otto 341: .It T
342: Toggle the display of process threads.
1.40 jmc 343: .It u Ar user
1.45 jmc 344: Show only those processes owned by
1.40 jmc 345: .Ar user .
346: .Sq u+
347: shows processes belonging to all users.
1.2 downsj 348: .El
349: .Sh THE DISPLAY
350: .\" The actual display varies depending on the specific variant of Unix
351: .\" that the machine is running. This description may not exactly match
352: .\" what is seen by top running on this particular machine. Differences
353: .\" are listed at the end of this manual entry.
354: .\" .Pp
1.1 downsj 355: The top few lines of the display show general information
356: about the state of the system, including
1.11 millert 357: .\" the last process ID assigned to a process,
1.2 downsj 358: .\" (on most systems),
1.24 millert 359: the three load average numbers,
1.1 downsj 360: the current time,
361: the number of existing processes,
362: the number of processes in each state
1.26 jaredy 363: (starting, running, idle, stopped, zombie, dead, and on processor),
1.1 downsj 364: and a percentage of time spent in each of the processor states
1.26 jaredy 365: (user, nice, system, interrupt, and idle).
1.17 aaron 366: It also includes information about physical and virtual memory allocation.
1.24 millert 367: The load average numbers give the number of jobs in the run queue averaged
1.26 jaredy 368: over 1, 5, and 15 minutes.
1.2 downsj 369: .Pp
1.1 downsj 370: The remainder of the screen displays information about individual
1.13 aaron 371: processes.
372: This display is similar in spirit to
1.2 downsj 373: .Xr ps 1
1.13 aaron 374: but it is not exactly the same.
1.26 jaredy 375: The following fields are displayed:
376: .Bl -tag -width USERNAME -offset indent
377: .It PID
378: The process ID.
379: .It USERNAME
380: The name of the process's owner.
381: .It UID
382: Used instead of USERNAME if
1.2 downsj 383: .Fl u
1.26 jaredy 384: is specified.
385: .It PRI
386: The current priority of the process.
387: .It NICE
388: The nice amount (in the range \-20 to 20).
389: .It SIZE
390: The total size of the process (the text, data, and stack segments).
391: .It RES
392: The current amount of resident memory.
393: .It STATE
394: The current state (one of
395: .Li start ,
396: .Li run ,
1.2 downsj 397: .Li sleep ,
1.26 jaredy 398: .Li stop ,
399: .Li idle ,
1.2 downsj 400: .Li zomb ,
1.26 jaredy 401: .Li dead ,
1.2 downsj 402: or
1.26 jaredy 403: .Li onproc ) .
404: On multi-processor systems, this is followed by a slash and the CPU
405: number on which the process is bound.
406: .It WAIT
407: A description of the wait channel the process is sleeping on if it's
408: asleep.
409: .It TIME
410: The number of system and user CPU seconds that the process has used.
411: .It CPU
412: The raw percentage of CPU usage and the default field on which the
413: display is sorted.
414: .It COMMAND
415: The name of the command that the process is currently running.
416: (If the process is swapped out, this column is enclosed by angle
417: brackets.)
418: .El
1.2 downsj 419: .Sh ENVIRONMENT
1.26 jaredy 420: .Bl -tag -width Ev
1.2 downsj 421: .It Ev TOP
422: User-configurable defaults for options.
423: .El
424: .Sh FILES
1.26 jaredy 425: .Bl -tag -width Pa -compact
1.2 downsj 426: .It Pa /dev/kmem
427: kernel memory
428: .It Pa /dev/mem
429: physical memory
1.26 jaredy 430: .It Pa /etc/passwd
431: used to map user ID to name
1.2 downsj 432: .It Pa /bsd
433: kernel image
1.14 aaron 434: .El
1.13 aaron 435: .Sh SEE ALSO
1.30 jmc 436: .Xr fstat 1 ,
1.13 aaron 437: .Xr kill 1 ,
1.30 jmc 438: .Xr netstat 1 ,
1.13 aaron 439: .Xr ps 1 ,
440: .Xr stty 1 ,
441: .Xr systat 1 ,
442: .Xr mem 4 ,
1.30 jmc 443: .Xr iostat 8 ,
444: .Xr pstat 8 ,
445: .Xr renice 8 ,
1.31 jmc 446: .Xr vmstat 8
1.16 aaron 447: .Sh AUTHORS
448: William LeFebvre, EECS Department, Northwestern University
1.2 downsj 449: .Sh BUGS
1.1 downsj 450: As with
1.2 downsj 451: .Xr ps 1 ,
1.1 downsj 452: things can change while
1.2 downsj 453: .Nm
1.13 aaron 454: is collecting information for an update.
455: The picture it gives is only a
1.1 downsj 456: close approximation to reality.