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