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