]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/top/top.1
top(1): Use standard boolean rather than homegrown alternative
[FreeBSD/FreeBSD.git] / usr.bin / top / top.1
1 .\" NOTE:  changes to the manual page for "top" should be made in the
2 .\"        file "top.X" and NOT in the file "top.1".
3 .\" $FreeBSD$
4 .nr N -1
5 .nr D 2
6 .TH TOP 1 Local
7 .UC 4
8 .SH NAME
9 top \- display and update information about the top cpu processes
10 .SH SYNOPSIS
11 .B top
12 [
13 .B \-abCHIijnPqStuvwz
14 ] [
15 .BI \-d count
16 ] [
17 .BI \-m io | cpu
18 ] [
19 .BI \-o field
20 ] [
21 .BI \-s time
22 ] [
23 .BI \-J jail
24 ] [
25 .BI \-U username
26 ] [
27 .I number
28 ]
29 .SH DESCRIPTION
30 .\" This defines appropriate quote strings for nroff and troff
31 .ds lq \&"
32 .ds rq \&"
33 .if t .ds lq ``
34 .if t .ds rq ''
35 .\" Just in case these number registers aren't set yet...
36 .if \nN==0 .nr N 10
37 .if \nD==0 .nr D 2
38 .I Top
39 displays the top
40 .if !\nN==-1 \nN
41 processes on the system and periodically updates this information.
42 .if \nN==-1 \
43 \{\
44 If standard output is an intelligent terminal (see below) then
45 as many processes as will fit on the terminal screen are displayed
46 by default.  Otherwise, a good number of them are shown (around 20).
47 .\}
48 Raw cpu percentage is used to rank the processes.  If
49 .I number
50 is given, then the top
51 .I number
52 processes will be displayed instead of the default.
53 .PP
54 .I Top
55 makes a distinction between terminals that support advanced capabilities
56 and those that do not.  This
57 distinction affects the choice of defaults for certain options.  In the
58 remainder of this document, an \*(lqintelligent\*(rq terminal is one that
59 supports cursor addressing, clear screen, and clear to end of line.
60 Conversely, a \*(lqdumb\*(rq terminal is one that does not support such
61 features.  If the output of
62 .I top
63 is redirected to a file, it acts as if it were being run on a dumb
64 terminal.
65 .SH OPTIONS
66 .TP
67 .B \-C
68 Toggle CPU display mode.
69 By default top displays the weighted CPU percentage in the WCPU column
70 (this is the same value that
71 .IR ps (1)
72 displays as CPU).
73 Each time
74 .B \-C
75 flag is passed it toggles between \*(lqraw cpu\*(rq mode
76 and \*(lqweighted cpu\*(rq mode, showing the \*(lqCPU\*(rq or
77 the \*(lqWCPU\*(rq column respectively.
78 .TP
79 .B \-S
80 Show system processes in the display.  Normally, system processes such as
81 the pager and the swapper are not shown.  This option makes them visible.
82 .TP
83 .B \-a
84 Display command names derived from the argv[] vector, rather than real
85 executable name. It's useful when you want to watch applications, that
86 puts their status information there. If the real name differs from argv[0],
87 it will be displayed in parenthesis.
88 .TP
89 .B \-b
90 Use \*(lqbatch\*(rq mode.  In this mode, all input from the terminal is
91 ignored.  Interrupt characters (such as ^C and ^\e) still have an effect.
92 This is the default on a dumb terminal, or when the output is not a terminal.
93 .TP
94 .B \-H
95 Display each thread for a multithreaded process individually.
96 By default a single summary line is displayed for each process.
97 .TP
98 .B \-i
99 Use \*(lqinteractive\*(rq mode.  In this mode, any input is immediately
100 read for processing.  See the section on \*(lqInteractive Mode\*(rq
101 for an explanation of
102 which keys perform what functions.  After the command is processed, the
103 screen will immediately be updated, even if the command was not
104 understood.  This mode is the default when standard output is an
105 intelligent terminal.
106 .TP
107 .B \-I
108 Do not display idle processes.
109 By default, top displays both active and idle processes.
110 .TP
111 .B \-j
112 Display the
113 .IR jail (8)
114 ID.
115 .TP
116 .B \-t
117 Do not display the
118 .I top
119 process.
120 .TP
121 .BI \-m display
122 Display either 'cpu' or 'io' statistics.  Default is 'cpu'.
123 .TP
124 .B \-n
125 Use \*(lqnon-interactive\*(rq mode.  This is identical to \*(lqbatch\*(rq
126 mode.
127 .TP
128 .B \-P
129 Display per-cpu CPU usage statistics.
130 .TP
131 .B \-q
132 Renice
133 .I top
134 to -20 so that it will run faster.  This can be used when the system is
135 being very sluggish to improve the possibility of discovering the problem.
136 This option can only be used by root.
137 .TP
138 .B \-u
139 Do not take the time to map uid numbers to usernames.  Normally,
140 .I top
141 will read as much of the file \*(lq/etc/passwd\*(rq as is necessary to map
142 all the user id numbers it encounters into login names.  This option
143 disables all that, while possibly decreasing execution time.  The uid
144 numbers are displayed instead of the names.
145 .TP
146 .B \-v
147 Write version number information to stderr then exit immediately.
148 false other processing takes place when this option is used.  To see current
149 revision information while top is running, use the help command \*(lq?\*(rq.
150 .TP
151 .B \-w
152 Display approximate swap usage for each process.
153 .TP
154 .B \-z
155 Do not display the system idle process.
156 .TP
157 .BI \-d count
158 Show only
159 .I count
160 displays, then exit.  A display is considered to be one update of the
161 screen.  This option allows the user to select the number of displays he
162 wants to see before
163 .I top
164 automatically exits.  For intelligent terminals, no upper limit
165 is set.  The default is 1 for dumb terminals. Please, note that for
166 .I count
167 = 1
168 no information is available about the percentage of time spent by the CPU in every state.
169 .TP
170 .BI \-s time
171 Set the delay between screen updates to
172 .I time
173 seconds.  The default delay between updates is \nD seconds.
174 .TP
175 .BI \-o field
176 Sort the process display area on the specified field.  The field name
177 is the name of the column as seen in the output, but in lower case:
178 \*(lqcpu\*(lq, \*(rqsize\*(lq, \*(rqres\*(lq, \*(rqtime\*(lq,
179 \*(rqpri\*(lq, \*(rqthreads\*(lq, \*(lqtotal\*(lq, \*(rqread\*(lq,
180 \*(rqwrite\*(lq, \*(rqfault\*(lq, \*(rqvcsw\*(lq, \*(rqivcsw\*(lq,
181 \*(lqjid\*(lq, \*(rqswap\*(lq or \*(rqpid\*(lq.
182 .TP
183 .BI \-J jail
184 Show only those processes owned by
185 .IR jail .
186 This may be either the
187 .B jid
188 or
189 .B name
190 of the jail.
191 Use
192 .B 0
193 to limit to host processes.
194 Using this option implies the
195 .B \-j
196 flag.
197 .PP
198 .BI \-U username
199 Show only those processes owned by
200 .IR username .
201 This option currently only accepts usernames and will not understand
202 uid numbers.
203 .PP
204 Both
205 .I count
206 and
207 .I number
208 fields can be specified as \*(lqinfinite\*(rq, indicating that they can
209 stretch as far as possible.  This is accomplished by using any proper
210 prefix of the keywords
211 \*(lqinfinity\*(rq,
212 \*(lqmaximum\*(rq,
213 or
214 \*(lqall\*(rq.
215 The default for
216 .I count
217 on an intelligent terminal is, in fact,
218 .BI infinity .
219 .PP
220 The environment variable
221 .B TOP
222 is examined for options before the command line is scanned.  This enables
223 a user to set his or her own defaults.  The number of processes to display
224 can also be specified in the environment variable
225 .BR TOP .
226 The options
227 .BR \-a ,
228 .BR \-C ,
229 .BR \-H ,
230 .BR \-I ,
231 .BR \-j ,
232 .BR \-P ,
233 .BR \-S ,
234 .BR \-t ,
235 .BR \-u ,
236 .BR \-w ,
237 and
238 .B \-z
239 are actually toggles.  A second specification of any of these options
240 will negate the first.  Thus a user who has the environment variable
241 .B TOP
242 set to \*(lq\-I\*(rq may use the command \*(lqtop \-I\*(rq to see idle processes.
243 .SH "INTERACTIVE MODE"
244 When
245 .I top
246 is running in \*(lqinteractive mode\*(rq, it reads commands from the
247 terminal and acts upon them accordingly.  In this mode, the terminal is
248 put in \*(lqCBREAK\*(rq, so that a character will be
249 processed as soon as it is typed.  Almost always, a key will be
250 pressed when
251 .I top
252 is between displays; that is, while it is waiting for
253 .I time
254 seconds to elapse.  If this is the case, the command will be
255 processed and the display will be updated immediately thereafter
256 (reflecting any changes that the command may have specified).  This
257 happens even if the command was incorrect.  If a key is pressed while 
258 .I top
259 is in the middle of updating the display, it will finish the update and
260 then process the command.  Some commands require additional information,
261 and the user will be prompted accordingly.  While typing this information
262 in, the user's erase and kill keys (as set up by the command
263 .IR stty )
264 are recognized, and a newline terminates the input.
265 .PP
266 These commands are currently recognized (^L refers to control-L):
267 .TP
268 .B ^L
269 Redraw the screen.
270 .IP "\fBh\fP\ or\ \fB?\fP"
271 Display a summary of the commands (help screen).  Version information
272 is included in this display.
273 .TP
274 .B q
275 Quit
276 .IR top.
277 .TP
278 .B d
279 Change the number of displays to show (prompt for new number).
280 Remember that the next display counts as one, so typing
281 .B d1
282 will make
283 .I top
284 show one final display and then immediately exit.
285 .TP
286 .B m
287 Toggle the display between 'cpu' and 'io' modes.
288 .TP
289 .B n or #
290 Change the number of processes to display (prompt for new number).
291 .TP
292 .B s
293 Change the number of seconds to delay between displays
294 (prompt for new number).
295 .TP
296 .B S
297 Toggle the display of system processes.
298 .TP
299 .B a
300 Toggle the display of process titles.
301 .TP
302 .B k
303 Send a signal (\*(lqkill\*(rq by default) to a list of processes.  This
304 acts similarly to the command
305 .IR kill (1)).
306 .TP
307 .B r
308 Change the priority (the \*(lqnice\*(rq) of a list of processes.
309 This acts similarly to the command
310 .IR renice (8)).
311 .TP
312 .B u
313 Display only processes owned by a specific set of usernames (prompt for
314 username).  If the username specified is simply \*(lq+\*(rq or \*(lq-\*(rq,
315 then processes belonging to all users will be displayed. Usernames can be added
316 to and removed from the set by prepending them with \*(lq+\*(rq and
317 \*(lq-\*(rq, respectively.
318 .TP
319 .B o
320 Change the order in which the display is sorted.  This command is not
321 available on all systems.  The sort key names vary from system to system
322 but usually include:  \*(lqcpu\*(rq, \*(lqres\*(rq, \*(lqsize\*(rq,
323 \*(lqtime\*(rq.  The default is cpu.
324 .TP
325 .B e
326 Display a list of system errors (if any) generated by the last
327 .BR k ill
328 or
329 .BR r enice
330 command.
331 .TP
332 .B H
333 Toggle the display of threads.
334 Also toggles the display of PID or TID.
335 .TP
336 .B i
337 (or
338 .BR I )
339 Toggle the display of idle processes.
340 .TP
341 .B j
342 Toggle the display of
343 .IR jail (8)
344 ID.
345 .TP
346 .B J
347 Display only processes owned by a specific jail (prompt for jail).
348 If the jail specified is simply \*(lq+\*(rq, then processes belonging
349 to all jails and the host will be displayed.
350 This will also enable the display of JID.
351 .TP
352 .B P
353 Toggle the display of per-CPU statistics.
354 .TP
355 .B t
356 Toggle the display of the
357 .I top
358 process.
359 .TP
360 .B w
361 Toggle the display of swap usage.
362 .TP
363 .B z
364 Toggle the display of the system idle process.
365 .SH "THE DISPLAY"
366 The actual display varies depending on the specific variant of Unix
367 that the machine is running.  This description may not exactly match
368 what is seen by top running on this particular machine.  Differences
369 are listed at the end of this manual entry.
370 .PP
371 The top few lines of the display show general information
372 about the state of the system, including
373 the last process id assigned to a process (on most systems),
374 the three load averages,
375 the current time,
376 the number of existing processes,
377 the number of processes in each state
378 (sleeping, running, starting, zombies, and stopped),
379 and a percentage of time spent in each of the processor states
380 (user, nice, system, and idle).
381 It also includes information about physical and virtual memory allocation.
382 .PP
383 The remainder of the screen displays information about individual
384 processes.  This display is similar in spirit to
385 .IR ps (1)
386 but it is not exactly the same.  PID is the process id, 
387 JID, when displayed, is the 
388 .IR jail (8)
389 ID corresponding to the process,
390 USERNAME is the name of the process's owner (if
391 .B \-u
392 is specified, a UID column will be substituted for USERNAME),
393 PRI is the current priority of the process,
394 NICE is the nice amount (in the range \-20 to 20),
395 SIZE is the total size of the process (text, data, and stack),
396 RES is the current amount of resident memory,
397 SWAP is the approximate amount of swap, if enabled
398 (SIZE, RES and SWAP are given in kilobytes),
399 STATE is the current state (one of \*(lqSTART\*(rq, \*(lqRUN\*(rq
400 (shown as \*(lqCPUn\*(rq on SMP systems), \*(lqSLEEP\*(rq, \*(lqSTOP\*(rq,
401 \*(lqZOMB\*(rq, \*(lqWAIT\*(rq, \*(lqLOCK\*(rq or the event on which the
402 process waits),
403 C is the processor number on which the process is executing
404 (visible only on SMP systems),
405 TIME is the number of system and user cpu seconds that the process has used,
406 WCPU, when displayed, is the weighted cpu percentage (this is the same
407 value that
408 .IR ps (1)
409 displays as CPU),
410 CPU is the raw percentage and is the field that is sorted to determine
411 the order of the processes, and
412 COMMAND is the name of the command that the process is currently running
413 (if the process is swapped out, this column is marked \*(lq<swapped>\*(rq).
414 .SH NOTES
415 If a process is in the \*(lqSLEEP\*(rq or \*(lqLOCK\*(rq state,
416 the state column will report the name of the event or lock on which the
417 process is waiting.
418 Lock names are prefixed with an asterisk \*(lq*\*(rq while sleep events
419 are not.
420 .SH AUTHOR
421 William LeFebvre, EECS Department, Northwestern University
422 .SH ENVIRONMENT
423 .DT
424 TOP     user-configurable defaults for options.
425 .SH FILES
426 .DT
427 /dev/kmem               kernel memory
428 .br
429 /dev/mem                physical memory
430 .br
431 /etc/passwd             used to map uid numbers to user names
432 .br
433 /boot/kernel/kernel     system image
434 .SH BUGS
435 Don't shoot me, but the default for
436 .B \-I
437 has changed once again.  So many people were confused by the fact that
438 .I top
439 wasn't showing them all the processes that I have decided to make the
440 default behavior show idle processes, just like it did in version 2.
441 But to appease folks who can't stand that behavior, I have added the
442 ability to set \*(lqdefault\*(rq options in the environment variable
443 .B TOP
444 (see the OPTIONS section).  Those who want the behavior that version
445 3.0 had need only set the environment variable
446 .B TOP
447 to \*(lq\-I\*(rq.
448 .PP
449 The command name for swapped processes should be tracked down, but this
450 would make the program run slower.
451 .PP
452 As with
453 .IR ps (1),
454 things can change while
455 .I top
456 is collecting information for an update.  The picture it gives is only a
457 close approximation to reality.
458 .SH SEE ALSO
459 kill(1),
460 ps(1),
461 stty(1),
462 mem(4),
463 getrusage(2),
464 renice(8)
465 .SH "FreeBSD NOTES"
466
467 .SH DESCRIPTION OF MEMORY
468 Mem: 61M Active, 86M Inact, 368K Laundry, 22G Wired, 102G Free
469 ARC: 15G Total, 9303M MFU, 6155M MRU, 1464K Anon, 98M Header, 35M Other
470      15G Compressed, 27G Uncompressed, 1.75:1 Ratio, 174M Overhead
471 Swap: 4096M Total, 532M Free, 13% Inuse, 80K In, 104K Out
472 .TP
473 .B K:
474 Kilobyte
475 .TP
476 .B M:
477 Megabyte
478 .TP
479 .B G:
480 Gigabyte
481 .TP
482 .B %:
483 1/100
484 .SS Physical Memory Stats
485 .TP
486 .B Active:
487 number of bytes active
488 .TP
489 .B Inact:
490 number of clean bytes inactive
491 .TP
492 .B Laundry:
493 number of dirty bytes queued for laundering
494 .TP
495 .B Wired:
496 number of bytes wired down, including BIO-level cached file data pages
497 .TP
498 .B Buf:
499 number of bytes used for BIO-level disk caching
500 .TP
501 .B Free:
502 number of bytes free
503 .SS ZFS ARC Stats
504 These stats are only displayed when the ARC is in use.
505 .TP
506 .B Total:
507 number of wired bytes used for the ZFS ARC
508 .TP
509 .B MRU:
510 number of ARC bytes holding most recently used data
511 .TP
512 .B MFU:
513 number of ARC bytes holding most frequently used data
514 .TP
515 .B Anon:
516 number of ARC bytes holding in flight data
517 .TP
518 .B Header:
519 number of ARC bytes holding headers
520 .TP
521 .B Other:
522 miscellaneous ARC bytes
523 .TP
524 .B Compressed:
525 bytes of memory used by ARC caches
526 .TP
527 .B Uncompressed:
528 bytes of data stored in ARC caches before compression
529 .TP
530 .B Ratio:
531 compression ratio of data cached in the ARC
532 .SS Swap Stats
533 .TP
534 .B Total:
535 total available swap usage
536 .TP
537 .B Free:
538 total free swap usage
539 .TP
540 .B Inuse:
541 swap usage
542 .TP
543 .B In:
544 bytes paged in from swap devices (last interval)
545 .TP
546 .B Out:
547 bytes paged out to swap devices (last interval)