xref: /freebsd/usr.bin/vmstat/vmstat.8 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1.\" Copyright (c) 1986, 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.\" 3. 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.Dd June 21, 2021
29.Dt VMSTAT 8
30.Os
31.Sh NAME
32.Nm vmstat
33.Nd report virtual memory statistics
34.Sh SYNOPSIS
35.Nm
36.\" .Op Fl fimst
37.Op Fl -libxo
38.Op Fl afHhimoPsz
39.Op Fl M Ar core Op Fl N Ar system
40.Op Fl c Ar count
41.Op Fl n Ar devs
42.Oo
43.Fl p
44.Sm off
45.Ar type , if , pass
46.Sm on
47.Oc
48.Op Fl w Ar wait
49.Op Ar disks ...
50.Op wait Op count
51.Sh DESCRIPTION
52The
53.Nm
54utility reports certain kernel statistics kept about process, virtual memory,
55disk, trap and cpu activity.
56.Pp
57If the
58.Fl M
59option is not specified, information is obtained from
60the currently running kernel via the
61.Xr sysctl 3
62interface.
63Otherwise, information is read from the specified core file,
64using the name list from the specified kernel image (or from
65the default image).
66.Pp
67The options are as follows:
68.Bl -tag -width indent
69.It Fl -libxo
70Generate output via
71.Xr libxo 3
72in a selection of different human and machine readable formats.
73See
74.Xr xo_parse_args 3
75for details on command line arguments.
76.It Fl a
77When used with
78.Fl i ,
79include statistics about interrupts that have never been generated.
80.It Fl c
81Repeat the display
82.Ar count
83times.
84The first display is for the time since a reboot and each subsequent
85report is for the time period since the last display.
86If no repeat
87.Ar count
88is specified, and
89.Fl w
90is specified, the default is infinity, otherwise the default is one.
91.It Fl f
92Report on the number
93.Xr fork 2 ,
94.Xr vfork 2
95and
96.Xr rfork 2
97system calls since system startup, and the number of pages of virtual memory
98involved in each.
99.It Fl h
100Changes memory columns into more easily human readable form.
101The default if
102standard output is a terminal device.
103.It Fl H
104Changes memory columns into straight numbers.
105The default if standard output
106is not a terminal device (such as a script).
107.It Fl i
108Report on the number of interrupts taken by each device since system
109startup.
110.It Fl M
111Extract values associated with the name list from the specified
112.Ar core .
113.It Fl N
114If
115.Fl M
116is also specified,
117extract the name list from the specified
118.Ar system
119instead of the default,
120which is the kernel image the system has booted from.
121.It Fl m
122Report on the usage of kernel dynamic memory allocated using
123.Xr malloc 9
124by type.
125.It Fl n
126Change the maximum number of disks to display from the default of 2.
127.It Fl o
128Display a list of virtual memory objects in the system and the resident
129memory used by each object.
130.It Fl P
131Report per-cpu system/user/idle cpu statistics.
132.It Fl p
133Specify which types of devices to display.
134There are three different
135categories of devices:
136.Pp
137.Bl -tag -width indent -compact
138.It device type:
139.Bl -tag -width 9n -compact
140.It da
141Direct Access devices
142.It sa
143Sequential Access devices
144.It printer
145Printers
146.It proc
147Processor devices
148.It worm
149Write Once Read Multiple devices
150.It cd
151CD devices
152.It scanner
153Scanner devices
154.It optical
155Optical Memory devices
156.It changer
157Medium Changer devices
158.It comm
159Communication devices
160.It array
161Storage Array devices
162.It enclosure
163Enclosure Services devices
164.It floppy
165Floppy devices
166.El
167.Pp
168.It interface:
169.Bl -tag -width 9n -compact
170.It IDE
171Integrated Drive Electronics devices
172.It SCSI
173Small Computer System Interface devices
174.It NVME
175NVM Express Interface devices
176.It other
177Any other device interface
178.El
179.Pp
180.It passthrough:
181.Bl -tag -width 9n -compact
182.It pass
183Passthrough devices
184.El
185.El
186.Pp
187The user must specify at least one device type, and may specify at most
188one device type from each category.
189Multiple device types in a single
190device type statement must be separated by commas.
191.Pp
192Any number of
193.Fl p
194arguments may be specified on the command line.
195All
196.Fl p
197arguments are ORed together to form a matching expression against which
198all devices in the system are compared.
199Any device that fully matches
200any
201.Fl p
202argument will be included in the
203.Nm
204output, up to two devices, or the maximum number of devices specified
205by the user.
206.It Fl s
207Display the contents of the
208.Em sum
209structure, giving the total number of several kinds of paging related
210events which have occurred since system startup.
211.It Fl w
212Pause
213.Ar wait
214seconds between each display.
215If no repeat
216.Ar wait
217interval is specified, the default is 1 second.
218The
219.Nm
220command will accept and honor a non-integer number of seconds.
221.It Fl z
222Report on memory used by the kernel zone allocator,
223.Xr uma 9 ,
224by zone.
225.El
226.Pp
227The
228.Ar wait
229and
230.Ar count
231arguments may be given after their respective flags at any point
232on the command line before the
233.Ar disks
234argument(s), or without their flags, as the final argument(s).
235The latter form is accepted for backwards compatibility, but it is
236preferred to use the forms with
237.Fl w
238and
239.Fl c
240to avoid ambiguity.
241.Pp
242By default,
243.Nm
244displays the following information:
245.Bl -tag -width indent
246.It procs
247Information about the number of threads in various states:
248.Pp
249.Bl -tag -width indent -compact
250.It r
251running or in run queue
252.It b
253blocked for resources (i/o, paging, etc.)
254.It w
255swapped out
256.El
257.It memory
258Information about the usage of virtual and real memory.
259.Pp
260Mapped virtual memory is a sum of all of the virtual pages belonging
261to mapped virtual memory objects.
262Note that the entire memory object's size is considered mapped even if
263only a subset of the object's pages are currently mapped.
264This statistic is not related to the active page queue which is used to track
265real memory.
266.Pp
267.Bl -tag -width indent -compact
268.It avm
269mapped virtual memory
270.Po previously called active in
271.Nm
272output
273.Pc
274.It fre
275size of the free list
276.El
277.It page
278Information about page faults and paging activity.
279These are given in units per second.
280.Pp
281.Bl -tag -width indent -compact
282.It flt
283total number of page faults
284.It re
285pages reactivated (found in laundry or inactive queues)
286.\" .It at
287.\" pages attached (found in free list)
288.It pi
289pages paged in
290.It po
291pages paged out
292.It fr
293pages freed
294.\" .It de
295.\" anticipated short term memory shortfall
296.It sr
297pages scanned by page daemon
298.El
299.It disks
300Disk operations per second (this field is system dependent).
301Typically paging will be split across the available drives.
302The header of the field is the first two characters of the disk name and
303the unit number.
304If more than two disk drives are configured in the system,
305.Nm
306displays only the first two drives, unless the user specifies the
307.Fl n
308argument to increase the number of drives displayed.
309This will probably
310cause the display to exceed 80 columns, however.
311To force
312.Nm
313to display specific drives, their names may be supplied on the command line.
314The
315.Nm
316utility
317defaults to show disks first, and then various other random devices in the
318system to add up to two devices, if there are that many devices in the
319system.
320If devices are specified on the command line, or if a device type
321matching pattern is specified (see above),
322.Nm
323will only display the given devices or the devices matching the pattern,
324and will not randomly select other devices in the system.
325.It faults
326Trap/interrupt rates per second.
327.Pp
328.Bl -tag -width indent -compact
329.It in
330device interrupts (including clock interrupts)
331.It sy
332system calls
333.It cs
334cpu context switches
335.El
336.It cpu
337Breakdown of percentage usage of CPU time.
338.Pp
339.Bl -tag -width indent -compact
340.It us
341user time for normal and low priority processes
342.It sy
343system and interrupt time
344.It id
345cpu idle
346.El
347.El
348.Sh FILES
349.Bl -tag -width /boot/kernel/kernel -compact
350.It Pa /boot/kernel/kernel
351default kernel namelist
352.It Pa /dev/kmem
353default memory file
354.El
355.Sh EXAMPLES
356The command:
357.Dl vmstat -w 5
358will print what the system is doing every five
359seconds.
360.Pp
361The command:
362.Dl vmstat -p da -p cd -w 1
363will tell vmstat to select the first two direct access or CDROM devices
364and display statistics on those devices, as well as other systems
365statistics every second.
366.Sh SEE ALSO
367.Xr fstat 1 ,
368.Xr netstat 1 ,
369.Xr nfsstat 1 ,
370.Xr ps 1 ,
371.Xr systat 1 ,
372.Xr libmemstat 3 ,
373.Xr libxo 3 ,
374.Xr xo_parse_args 3 ,
375.Xr gstat 8 ,
376.Xr iostat 8 ,
377.Xr pstat 8 ,
378.Xr sysctl 8 ,
379.Xr malloc 9 ,
380.Xr uma 9
381.Pp
382The sections starting with ``Interpreting system activity'' in
383.%T "Installing and Operating 4.3BSD" .
384.Sh HISTORY
385The
386.Nm
387utility first appeared in
388.Bx 3 .
389.Sh BUGS
390The
391.Fl c
392and
393.Fl w
394options are only available with the default output.
395