When checking for binary file, check if ch is not EOF only ch actually got
[freebsd.git] / usr.bin / systat / systat.1
1 .\" Copyright (c) 1985, 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)systat.1    8.2 (Berkeley) 12/30/93
29 .\" $FreeBSD$
30 .\"
31 .Dd October 24, 2015
32 .Dt SYSTAT 1
33 .Os
34 .Sh NAME
35 .Nm systat
36 .Nd display system statistics
37 .Sh SYNOPSIS
38 .Nm
39 .Op Fl display
40 .Op Ar display-commands
41 .Op Ar refresh-interval
42 .Sh DESCRIPTION
43 The
44 .Nm
45 utility displays various system statistics in a screen oriented fashion
46 using the curses screen display library,
47 .Xr ncurses 3 .
48 .Pp
49 While
50 .Nm
51 is running the screen is usually divided into two windows (an exception
52 is the vmstat display which uses the entire screen).
53 The
54 upper window depicts the current system load average.
55 The
56 information displayed in the lower window may vary, depending on
57 user commands.
58 The last line on the screen is reserved for user
59 input and error messages.
60 .Pp
61 By default
62 .Nm
63 displays the processes getting the largest percentage of the processor
64 in the lower window.
65 Other displays show swap space usage, disk
66 .Tn I/O
67 statistics (a la
68 .Xr iostat 8 ) ,
69 virtual memory statistics (a la
70 .Xr vmstat 8 ) ,
71 .Tn TCP/IP
72 statistics,
73 and network connections (a la
74 .Xr netstat 1 ) .
75 .Pp
76 Input is interpreted at two different levels.
77 A ``global'' command interpreter processes all keyboard input.
78 If this command interpreter fails to recognize a command, the
79 input line is passed to a per-display command interpreter.
80 This
81 allows each display to have certain display-specific commands.
82 .Pp
83 Command line options:
84 .Bl -tag -width "refresh_interval"
85 .It Fl Ns Ar display
86 The
87 .Fl
88 flag expects
89 .Ar display
90 to be one of:
91 .Ic icmp ,
92 .Ic icmp6 ,
93 .Ic ifstat ,
94 .Ic iostat ,
95 .Ic ip ,
96 .Ic ip6 ,
97 .Ic netstat ,
98 .Ic pigs ,
99 .Ic sctp ,
100 .Ic swap ,
101 .Ic tcp ,
102 .Ic vmstat ,
103 or
104 .Ic zarc ,
105 These displays can also be requested interactively (without the
106 .Dq Fl )
107 and are described in
108 full detail below.
109 .It Ar refresh-interval
110 The
111 .Ar refresh-value
112 specifies the screen refresh time interval in seconds.
113 Time interval can be fractional.
114 .It Ar display-commands
115 A list of commands specific for this display. These commands can also
116 be entered interactively and are described for each display separately
117 below. If the command of the display requires an argument or arguments,
118 it is possible to specify them as separate command line argument. To finish
119 display commands it is possible to use double dash at the end
120 of the list. For example:
121 .Pp
122 .Dl Nm Fl ifstat Fl match Ar bge0,em1 Fl pps
123 .Pp
124 This will display statistics of packets per second for network interfaces
125 named as bge0 and em1.
126 .Pp
127 .Dl Nm Fl iostat Fl numeric Fl - Ar 2.1
128 .Pp
129 This will display all IO statistics in a numeric format and the information
130 will be refreshed each 2.1 seconds.
131 .El
132 .Pp
133 Certain characters cause immediate action by
134 .Nm .
135 These are
136 .Bl -tag -width Fl
137 .It Ic \&^L
138 Refresh the screen.
139 .It Ic \&^G
140 Print the name of the current ``display'' being shown in
141 the lower window and the refresh interval.
142 .It Ic \&:
143 Move the cursor to the command line and interpret the input
144 line typed as a command.
145 While entering a command the
146 current character erase, word erase, and line kill characters
147 may be used.
148 .El
149 .Pp
150 The following commands are interpreted by the ``global''
151 command interpreter.
152 .Bl -tag -width Fl
153 .It Ic help
154 Print the names of the available displays on the command line.
155 .It Ic load
156 Print the load average over the past 1, 5, and 15 minutes
157 on the command line.
158 .It Ic stop
159 Stop refreshing the screen.
160 .It Xo
161 .Op Ic start
162 .Op Ar number
163 .Xc
164 Start (continue) refreshing the screen.
165 If a second, numeric,
166 argument is provided it is interpreted as a refresh interval
167 (in seconds).
168 Supplying only a number will set the refresh interval to this
169 value.
170 .It Ic quit
171 Exit
172 .Nm .
173 (This may be abbreviated to
174 .Ic q . )
175 .El
176 .Pp
177 The available displays are:
178 .Bl -tag -width Ic
179 .It Ic pigs
180 Display, in the lower window, those processes resident in main
181 memory and getting the
182 largest portion of the processor (the default display).
183 When less than 100% of the
184 processor is scheduled to user processes, the remaining time
185 is accounted to the ``idle'' process.
186 .It Ic icmp
187 Display, in the lower window, statistics about messages received and
188 transmitted by the Internet Control Message Protocol
189 .Pq Dq Tn ICMP .
190 The left half of the screen displays information about received
191 packets, and the right half displays information regarding transmitted
192 packets.
193 .Pp
194 The
195 .Ic icmp
196 display understands two commands:
197 .Ic mode
198 and
199 .Ic reset .
200 The
201 .Ic mode
202 command is used to select one of four display modes, given as its argument:
203 .Bl -tag -width absoluteXX -compact
204 .It Ic rate :
205 show the rate of change of each value in packets (the default)
206 per second
207 .It Ic delta :
208 show the rate of change of each value in packets per refresh interval
209 .It Ic since :
210 show the total change of each value since the display was last reset
211 .It Ic absolute :
212 show the absolute value of each statistic
213 .El
214 .Pp
215 The
216 .Ic reset
217 command resets the baseline for
218 .Ic since
219 mode.
220 The
221 .Ic mode
222 command with no argument will display the current mode in the command
223 line.
224 .It Ic icmp6
225 This display is like the
226 .Ic icmp
227 display,
228 but displays statistics for IPv6 ICMP.
229 .It Ic ip
230 Otherwise identical to the
231 .Ic icmp
232 display, except that it displays
233 .Tn IP
234 and
235 .Tn UDP
236 statistics.
237 .It Ic ip6
238 Like the
239 .Ic ip
240 display,
241 except that it displays
242 .Tn IPv6
243 statistics.
244 It does not display
245 .Tn UDP statistics.
246 .It Ic sctp
247 Like
248 .Ic icmp ,
249 but with
250 .Tn SCTP
251 statistics.
252 .It Ic tcp
253 Like
254 .Ic icmp ,
255 but with
256 .Tn TCP
257 statistics.
258 .It Ic iostat
259 Display, in the lower window, statistics about processor use
260 and disk throughput.
261 Statistics on processor use appear as
262 bar graphs of the amount of time executing in user mode (``user''),
263 in user mode running low priority processes (``nice''), in
264 system mode (``system''), in interrupt mode (``interrupt''),
265 and idle (``idle'').
266 Statistics
267 on disk throughput show, for each drive, megabytes per second,
268 average number of disk transactions per second, and
269 average kilobytes of data per transaction.
270 This information may be
271 displayed as bar graphs or as rows of numbers which scroll downward.
272 Bar
273 graphs are shown by default.
274 .Pp
275 The following commands are specific to the
276 .Ic iostat
277 display; the minimum unambiguous prefix may be supplied.
278 .Pp
279 .Bl -tag -width Fl -compact
280 .It Cm numbers
281 Show the disk
282 .Tn I/O
283 statistics in numeric form.
284 Values are
285 displayed in numeric columns which scroll downward.
286 .It Cm bars
287 Show the disk
288 .Tn I/O
289 statistics in bar graph form (default).
290 .It Cm kbpt
291 Toggle the display of kilobytes per transaction.
292 (the default is to
293 not display kilobytes per transaction).
294 .El
295 .It Ic swap
296 Show information about swap space usage on all the
297 swap areas compiled into the kernel.
298 The first column is the device name of the partition.
299 The next column is the total space available in the partition.
300 The
301 .Ar Used
302 column indicates the total blocks used so far;
303 the graph shows the percentage of space in use on each partition.
304 If there are more than one swap partition in use,
305 a total line is also shown.
306 Areas known to the kernel, but not in use are shown as not available.
307 .It Ic vmstat
308 Take over the entire display and show a (rather crowded) compendium
309 of statistics related to virtual memory usage, process scheduling,
310 device interrupts, system name translation caching, disk
311 .Tn I/O
312 etc.
313 .Pp
314 The upper left quadrant of the screen shows the number
315 of users logged in and the load average over the last one, five,
316 and fifteen minute intervals.
317 Below this line are statistics on memory utilization.
318 The first row of the table reports memory usage only among
319 active processes, that is processes that have run in the previous
320 twenty seconds.
321 The second row reports on memory usage of all processes.
322 The first column reports on the number of kilobytes in physical pages
323 claimed by processes.
324 The second column reports the number of kilobytes in physical pages that
325 are devoted to read only text pages.
326 The third and fourth columns report the same two figures for
327 virtual pages, that is the number of kilobytes in pages that would be
328 needed if all processes had all of their pages.
329 Finally the last column shows the number of kilobytes in physical pages
330 on the free list.
331 .Pp
332 Below the memory display is a list of the
333 average number of processes (over the last refresh interval)
334 that are runnable (`r'), in page wait (`p'),
335 in disk wait other than paging (`d'),
336 sleeping (`s'), and swapped out but desiring to run (`w').
337 The row also shows the average number of context switches
338 (`Csw'), traps (`Trp'; includes page faults), system calls (`Sys'),
339 interrupts (`Int'), network software interrupts (`Sof'), and page
340 faults (`Flt').
341 .Pp
342 Below the process queue length listing is a numerical listing and
343 a bar graph showing the amount of
344 system (shown as `='), interrupt (shown as `+'), user (shown as `>'),
345 nice (shown as `-'), and idle time (shown as ` ').
346 .Pp
347 Below the process display are statistics on name translations.
348 It lists the number of names translated in the previous interval,
349 the number and percentage of the translations that were
350 handled by the system wide name translation cache, and
351 the number and percentage of the translations that were
352 handled by the per process name translation cache.
353 .Pp
354 To the right of the name translations display are lines showing
355 the number of dirty buffers in the buffer cache (`dtbuf'),
356 desired maximum size of vnode cache (`desvn'),
357 number of vnodes actually allocated (`numvn'),
358 and
359 number of allocated vnodes that are free (`frevn').
360 .Pp
361 At the bottom left is the disk usage display.
362 It reports the number of
363 kilobytes per transaction, transactions per second, megabytes
364 per second and the percentage of the time the disk was busy averaged
365 over the refresh period of the display (by default, five seconds).
366 The system keeps statistics on most every storage device.
367 In general, up
368 to seven devices are displayed.
369 The devices displayed by default are the
370 first devices in the kernel's device list.
371 See
372 .Xr devstat 3
373 and
374 .Xr devstat 9
375 for details on the devstat system.
376 .Pp
377 Under the date in the upper right hand quadrant are statistics
378 on paging and swapping activity.
379 The first two columns report the average number of pages
380 brought in and out per second over the last refresh interval
381 due to page faults and the paging daemon.
382 The third and fourth columns report the average number of pages
383 brought in and out per second over the last refresh interval
384 due to swap requests initiated by the scheduler.
385 The first row of the display shows the average
386 number of disk transfers per second over the last refresh interval;
387 the second row of the display shows the average
388 number of pages transferred per second over the last refresh interval.
389 .Pp
390 Below the paging statistics is a column of lines regarding the virtual
391 memory system.
392 The first few lines describe,
393 in units (except as noted below)
394 of pages per second averaged over the sampling interval,
395 pages copied on write (`cow'),
396 pages zero filled on demand (`zfod'),
397 pages optimally zero filled on demand (`ozfod'),
398 the ratio of the (average) ozfod / zfod as a percentage (`%ozfod'),
399 pages freed by the page daemon (`daefr'),
400 pages freed by exiting processes (`prcfr'),
401 total pages freed (`totfr'),
402 pages reactivated from the free list (`react'),
403 the average number of
404 times per second that the page daemon was awakened (`pdwak'),
405 pages analyzed by the page daemon (`pdpgs'),
406 and
407 in-transit blocking page faults (`intrn').
408 Note that the units are special for `%ozfod' and `pdwak'.
409 The next few lines describe,
410 as amounts of memory in kilobytes,
411 pages wired down (`wire'),
412 active pages (`act'),
413 inactive pages (`inact'),
414 pages on the cache queue (`cache'),
415 and
416 free pages (`free').
417 Note that the values displayed are the current transient ones;
418 they are not averages.
419 .Pp
420 At the bottom of this column is a line showing the
421 amount of virtual memory, in kilobytes, mapped into the buffer cache (`buf').
422 This statistic is not useful.
423 It exists only as a placeholder for the corresponding useful statistic
424 (the amount of real memory used to cache disks).
425 The most important component of the latter (the amount of real memory
426 used by the vm system to cache disks) is not available,
427 but can be guessed from the `inact' amount under some system loads.
428 .Pp
429 Running down the right hand side of the display is a breakdown
430 of the interrupts being handled by the system.
431 At the top of the list is the total interrupts per second
432 over the time interval.
433 The rest of the column breaks down the total on a device
434 by device basis.
435 Only devices that have interrupted at least once since boot time are shown.
436 .Pp
437 The following commands are specific to the
438 .Ic vmstat
439 display; the minimum unambiguous prefix may be supplied.
440 .Pp
441 .Bl -tag -width Ar -compact
442 .It Cm boot
443 Display cumulative statistics since the system was booted.
444 .It Cm run
445 Display statistics as a running total from the point this
446 command is given.
447 .It Cm time
448 Display statistics averaged over the refresh interval (the default).
449 .It Cm zero
450 Reset running statistics to zero.
451 .El
452 .It Ic zarc
453 display arc cache usage and hit/miss statistics.
454 .It Ic netstat
455 Display, in the lower window, network connections.
456 By default,
457 network servers awaiting requests are not displayed.
458 Each address
459 is displayed in the format ``host.port'', with each shown symbolically,
460 when possible.
461 It is possible to have addresses displayed numerically,
462 limit the display to a set of ports, hosts, and/or protocols
463 (the minimum unambiguous prefix may be supplied):
464 .Pp
465 .Bl -tag -width Ar -compact
466 .It Cm all
467 Toggle the displaying of server processes awaiting requests (this
468 is the equivalent of the
469 .Fl a
470 flag to
471 .Xr netstat 1 ) .
472 .It Cm numbers
473 Display network addresses numerically.
474 .It Cm names
475 Display network addresses symbolically.
476 .It Cm proto Ar protocol
477 Display only network connections using the indicated
478 .Ar protocol .
479 Supported protocols are ``tcp'', ``udp'', and ``all''.
480 .It Cm ignore Op Ar items
481 Do not display information about connections associated with
482 the specified hosts or ports.
483 Hosts and ports may be specified
484 by name (``vangogh'', ``ftp''), or numerically.
485 Host addresses
486 use the Internet dot notation (``128.32.0.9'').
487 Multiple items
488 may be specified with a single command by separating them with
489 spaces.
490 .It Cm display Op Ar items
491 Display information about the connections associated with the
492 specified hosts or ports.
493 As for
494 .Ar ignore ,
495 .Op Ar items
496 may be names or numbers.
497 .It Cm show Op Ar ports\&|hosts
498 Show, on the command line, the currently selected protocols,
499 hosts, and ports.
500 Hosts and ports which are being ignored
501 are prefixed with a `!'.
502 If
503 .Ar ports
504 or
505 .Ar hosts
506 is supplied as an argument to
507 .Cm show ,
508 then only the requested information will be displayed.
509 .It Cm reset
510 Reset the port, host, and protocol matching mechanisms to the default
511 (any protocol, port, or host).
512 .El
513 .It Ic ifstat
514 Display the network traffic going through active interfaces on the
515 system.
516 Idle interfaces will not be displayed until they receive some
517 traffic.
518 .Pp
519 For each interface being displayed, the current, peak and total
520 statistics are displayed for incoming and outgoing traffic.
521 By default,
522 the
523 .Ic ifstat
524 display will automatically scale the units being used so that they are
525 in a human-readable format.
526 The scaling units used for the current and
527 peak
528 traffic columns can be altered by the
529 .Ic scale
530 command.
531 .Bl -tag -width ".Cm scale Op Ar units"
532 .It Cm scale Op Ar units
533 Modify the scale used to display the current and peak traffic over all
534 interfaces.
535 The following units are recognised: kbit, kbyte, mbit,
536 mbyte, gbit, gbyte and auto.
537 .It Cm pps
538 Show statistics in packets per second instead of bytes/bits per second.
539 A subsequent call of
540 .Ic pps
541 switches this mode off.
542 .It Cm match Op Ar patterns
543 Display only interfaces that match pattern provided as an argument.
544 Patterns should be in shell syntax separated by whitespaces or commas.
545 If this command is called without arguments then all interfaces are displayed.
546 For example:
547 .Pp
548 .Dl match em0, bge1
549 .Pp
550 This will display em0 and bge1 interfaces.
551 .Pp
552 .Dl match em*, bge*, lo0
553 .Pp
554 This will display all
555 .Ic em
556 interfaces, all
557 .Ic bge
558 interfaces and the loopback interface.
559 .El
560 .El
561 .Pp
562 Commands to switch between displays may be abbreviated to the
563 minimum unambiguous prefix; for example, ``io'' for ``iostat''.
564 Certain information may be discarded when the screen size is
565 insufficient for display.
566 For example, on a machine with 10
567 drives the
568 .Ic iostat
569 bar graph displays only 3 drives on a 24 line terminal.
570 When
571 a bar graph would overflow the allotted screen space it is
572 truncated and the actual value is printed ``over top'' of the bar.
573 .Pp
574 The following commands are common to each display which shows
575 information about disk drives.
576 These commands are used to
577 select a set of drives to report on, should your system have
578 more drives configured than can normally be displayed on the
579 screen.
580 .Pp
581 .Bl -tag -width Ar -compact
582 .It Cm ignore Op Ar drives
583 Do not display information about the drives indicated.
584 Multiple
585 drives may be specified, separated by spaces.
586 .It Cm display Op Ar drives
587 Display information about the drives indicated.
588 Multiple drives
589 may be specified, separated by spaces.
590 .It Cm only Op Ar drives
591 Display only the specified drives.
592 Multiple drives may be specified,
593 separated by spaces.
594 .It Cm drives
595 Display a list of available devices.
596 .It Cm match Xo
597 .Ar type , Ns Ar if , Ns Ar pass
598 .Op | Ar ...
599 .Xc
600 Display devices matching the given pattern.
601 The basic matching
602 expressions are the same as those used in
603 .Xr iostat 8
604 with one difference.
605 Instead of specifying multiple
606 .Fl t
607 arguments which are then ORed together, the user instead specifies multiple
608 matching expressions joined by the pipe
609 .Pq Ql \&|
610 character.
611 The comma
612 separated arguments within each matching expression are ANDed together, and
613 then the pipe separated matching expressions are ORed together.
614 Any
615 device matching the combined expression will be displayed, if there is room
616 to display it.
617 For example:
618 .Pp
619 .Dl match da,scsi | cd,ide
620 .Pp
621 This will display all SCSI Direct Access devices and all IDE CDROM devices.
622 .Pp
623 .Dl match da | sa | cd,pass
624 .Pp
625 This will display all Direct Access devices, all Sequential Access devices,
626 and all passthrough devices that provide access to CDROM drives.
627 .El
628 .Sh FILES
629 .Bl -tag -width /boot/kernel/kernel -compact
630 .It Pa /boot/kernel/kernel
631 For the namelist.
632 .It Pa /dev/kmem
633 For information in main memory.
634 .It Pa /etc/hosts
635 For host names.
636 .It Pa /etc/networks
637 For network names.
638 .It Pa /etc/services
639 For port names.
640 .El
641 .Sh SEE ALSO
642 .Xr netstat 1 ,
643 .Xr kvm 3 ,
644 .Xr icmp 4 ,
645 .Xr icmp6 4 ,
646 .Xr ip 4 ,
647 .Xr ip6 4 ,
648 .Xr tcp 4 ,
649 .Xr udp 4 ,
650 .Xr gstat 8 ,
651 .Xr iostat 8 ,
652 .Xr vmstat 8
653 .Sh HISTORY
654 The
655 .Nm
656 program appeared in
657 .Bx 4.3 .
658 The
659 .Ic icmp ,
660 .Ic ip ,
661 and
662 .Ic tcp
663 displays appeared in
664 .Fx 3.0 ;
665 the notion of having different display modes for the
666 .Tn ICMP ,
667 .Tn IP ,
668 .Tn TCP ,
669 and
670 .Tn UDP
671 statistics was stolen from the
672 .Fl C
673 option to
674 .Xr netstat 1
675 in Silicon Graphics'
676 .Tn IRIX
677 system.
678 .Sh BUGS
679 Certain displays presume a minimum of 80 characters per line.
680 The
681 .Ic vmstat
682 display looks out of place because it is (it was added in as
683 a separate display rather than created as a new program).