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