An acronym for “Virtual Memory Statistics”, the vmstat command is a Linux utility for displaying statistics related to memory consumption, disk usage, and other system information. Without any further ado, let us get down to the analysis of vmstat command.
In case your system does not have the vmstat command, then no worries, as it comes under the package of 'sysstat'.
如果您的系统没有vmstat命令,那么不用担心,因为它在'sysstat'软件包下。
Debian/Ubuntu users can install the package by using the :
Debian / Ubuntu用户可以使用安装软件包:
sudo apt install sysstat
Whereas other Linux distribution users can install 'sysstat' using their standard installation commands.
其他Linux发行版用户可以使用其标准安装命令来安装'sysstat' 。
Before moving onto the explanation stuff, we first need to get root access as some information might be off-limits for certain users. This can be done by 'sudo -s' or 'sudo su'.
vmstat命令的基本输出 (Basic output of the vmstat command)
After completing all the obligations required for the setup, let us run 'vmstat' on the terminal.
完成设置所需的所有义务后,让我们在终端上运行'vmstat' 。
At first, the shady output is beyond comprehension for any Linux user. Let us try to cast some light on it. There are six sections in the output, with some non-indented statistics below:
r – The number of processes that are active in the system.
b – The number of sleepingprocesses.
procs –过程统计
r –系统中活动的进程数。
b – 睡眠进程数 。
memory – Memory statistics
swpd – The amount of virtual memory being used by the system. The swap space is initially unoccupied. but as the system’s physical memory is about the reach its limit, the kernel decides to use the swap partition.
free – The amount of freememory.
buff – The amount of memory that has been temporarily occupied as buffers.
si – The rate at which memory is swapped in from disk.
so – The rate at which memory is swapped out to disk.
swap –交换空间统计
si –从磁盘交换内存的速率 。
因此 – 内存换出到磁盘的速率 。
io – Input/Output Statistics
bi – The rate at which blocks are read from disk.
bo – The rate at which blocks are written to disk.
io –输入/输出统计
bi –从磁盘读取块的速率 。
bo –将块写入磁盘的速率 。
system – Scheduling statistics
in – The rate of system interrupts.
cs – The rate of context switches done by the scheduler.
系统 –计划统计
in – 系统中断的速率 。
cs –调度程序完成上下文切换的速率 。
cpu – CPU Statistics
us – The percentage of CPU time spent on user processes.
sy – The percentage of CPU time spent on kernel processes.
id – The percentage of idle CPU time.
wa – The percentage of CPU time spent waiting for Input/Output.
st – The percentage of CPU time stolen by a virtual machine.
cpu – CPU统计信息
us –在用户进程上花费的CPU时间的百分比。
sy –在内核进程上花费的CPU时间的百分比。
id – 空闲CPU时间的百分比。
wa –等待输入/输出花费的CPU时间的百分比。
st –虚拟机窃取的CPU时间的百分比。
The above statistics provided by the basic output are instantaneous, that is, the system information at that particular point of time. To get a timestamp along with the output, we can make use of '-t' option.
In order to get a series of 'vmstat' outputs, we need to run the following command:
为了获得一系列的'vmstat'输出,我们需要运行以下命令:
vmstat
This procedure is not very difficult to understand.
这个过程不是很难理解。
<DELAY> – Since, 'vmstat' provides discrete values we can specify the delay between each statistic, the command displays. <DELAY> –由于'vmstat'提供离散值,因此我们可以指定每个统计之间的延迟,命令显示。
<ITERATIONS> – The number of times we need the command to print the information. <ITERATIONS> –我们需要命令打印信息的次数。
Note: To run the command infinite number of times, (basically an infinite loop), we can omit the <ITERATIONS> parameter.
注意:要无限次运行命令(基本上是无限循环),我们可以省略<ITERATIONS>参数。
For instance, 'vmstat 1' displays statistics with a one-second delay indefinite number of times.
例如, 'vmstat 1'显示具有一秒延迟的统计信息,次数不确定。
内存和调度统计 (Memory and Scheduling Statistics)
We can display some extended information related to Memory, by running:
通过运行以下命令,我们可以显示一些与内存有关的扩展信息:
vmstat -s
These summary statistics are self-explainable.
这些汇总统计数据是不言自明的。
The first set of lines deals with the amount of memory being used in the system:
Total physical memory
Currently used memory
Active memory – used recently
Inactive memory – not used recently
Free memory
Buffer memory
Cache memory
Swap memory information
第一组行处理系统中使用的内存量:
总物理内存
当前使用的内存
活动内存 –最近使用
非活动内存 –最近未使用
可用内存
缓冲存储器
快取记忆体
交换内存信息
The following set of lines represents the CPU used in various ways:
CPU used for high priority user processes (not-nice)
Processor time used for less priority user processes (nice)
CPU for kernel processes
Idle CPU
Processor for input/output management
CPU for interrupt requests
Processor time used for software interrupts
CPU stolen by some virtual machine
以下几行代表以各种方式使用的CPU:
用于高优先级用户进程的CPU(不错)
优先级较低的用户进程所用的处理器时间(不错)
内核进程的 CPU
CPU闲置
输入/输出管理处理器
CPU的中断请求
用于软件中断的处理器时间
虚拟机窃取了CPU
Next up are values related paging in Operating System:
Number of pages paged in from virtual memory
The number of pages paged out to virtual memory
Number of pages read from swap memory
Number of pages written to swap memory
接下来是与操作系统中的分页有关的值:
虚拟内存中分页的页数
分页到虚拟内存的页面数
从交换内存读取的页数
写入交换内存的页数
The last set of numbers denote:
Number of interrupts since boot-time
Number context switches done by the system scheduler
The timestamp for the last boot-time
The number of forks done to create child processes. (This information can directly be obtained by running 'vmstat -f')
最后一组数字表示:
自启动以来的中断数
系统调度程序完成的上下文切换数量
上次启动时间的时间戳
创建子进程完成的派生数。 (可以通过运行'vmstat -f'直接获得此信息)
使用vmstat命令显示磁盘统计信息 (Display Disk Statistics Using vmstat Command)
The command provides a similar kind of statistics for disk usage. It can be accessed by:
该命令为磁盘使用情况提供了类似的统计信息。 可以通过以下方式访问它:
vmstat -D
Each entry displays some crucial information:
每个条目显示一些关键信息:
The number of disks present in the system. 系统中存在的磁盘数 。
The number of partitions in the system. 系统中的分区数 。
The total number of requested reads. 的请求总数读取 。
The number of merged reads for increasing performance. 合并读取的数量以提高性能。
The number of sectors already read from the disk. 已从磁盘读取的扇区数 。
The period of time spent on reading the disk in milliseconds. 读取磁盘所花费的时间(以毫秒为单位)。
The total number of requested writes. 总数要求写的。
The number of merged writes for increasing performance. 合并写入的数量以提高性能。
The number of sectors already written to the disk. 已经写入磁盘的扇区数 。
The period of time spent on writing to the disk in milliseconds. 写入磁盘所花费的时间(以毫秒为单位)。
The number of Input/Output currently inprogress. 当前正在进行的Input / Output数。
The period of time spent waiting for Input/Output. 等待Input / Output所花费的时间 。
Note: In certain versions of 'vmstat', the last two entries in the above output have beenimplemented incorrectly.
注意:在某些版本的'vmstat' ,上面输出中的最后两个条目是 实施不正确。
For detailed statistics on each disk usage, we can use '-d' option.
有关每个磁盘使用情况的详细统计信息,我们可以使用'-d'选项。
vmstat -d
The above output displays the same statistics for every specific disk present in the system.
上面的输出为系统中存在的每个特定磁盘显示相同的统计信息。
Linux内核的内存使用情况 (Memory usage by Linux kernel)
Linux kernel implements a slab-level of memory management, for efficient use of memory in the system. The vmstat command provides information related to slabs maintained by the Linux kernel.
The first column denotes the name of the slab (Cache). 第一列表示平板的名称 (缓存)。
It is followed by the number of objectscurrentlyheld in the slab (Num). 其次是平板中当前保存的对象数 (数字)。
Next up, is the total number of available objects present in the slab (Total). 接下来,是平板中存在的可用对象总数(总计)。
The next value is the size of the slab in bytes (Size). 下一个值是平板的大小(以字节为单位)(大小)。
The last value is the number of pages present in each slab (Pages). 的最后一个值是存在于每个板坯(页数)的页面数量 。
This pretty much sums up the important information presented by the 'vmstat' command.
这几乎总结了'vmstat'命令提供的重要信息。
结论 (Conclusion)
This concludes the guide to the usage of 'vmstat' command in Linux. In case, you are curious about some specifications of the command, then the manual pages will be the right path to follow.