linux vmstat_Linux中vmstat命令指南

linux vmstat

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.

vmstat命令是“虚拟内存统计信息”的首字母缩写,是一种Linux实用程序,用于显示与内存消耗,磁盘使用情况和其他系统信息有关的统计信息。 事不宜迟,让我们开始分析vmstat命令。

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 apt command:

Debian / Ubuntu用户可以使用apt命令安装软件包:


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'.

在继续进行介绍之前,我们首先需要获得root用户访问权限,因为某些信息可能对某些用户不可用。 这可以通过'sudo -s''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'

Vmstat Basic Output
Basic Output
基本输出

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:

最初,对于任何Linux用户来说,可疑的输出都是无法理解的。 让我们尝试对此有所启发。 输出中有六个部分,下面是一些非缩进的统计信息:

  • procs – Process Statistics
    • r – The number of processes that are active in the system.
    • b – The number of sleeping processes.

    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 free memory.
    • buff – The amount of memory that has been temporarily occupied as buffers.
    • cache – The amount of cache memory.

    内存 –内存统计信息
    • swpd –系统正在使用的虚拟内存量。 交换空间最初未被占用。 但是随着系统的物理内存即将达到其极限,内核决定使用交换分区。
    • free- 可用 内存量。
    • buff –暂时用作缓冲区内存量。
    • cache缓存内存量。
  • swap – Swap space Statistics
    • 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.

基本输出提供的以上统计信息是瞬时的,即该特定时间点的系统信息。 为了获得输出的时间戳,我们可以使用'-t'选项。


vmstat -t
Vmstat Basic Timestamp
Basic output of the vmstat command with Timestamp
带有时间戳的vmstat命令的基本输出


连续统计输出 (Continuous statistical output)

In order to get a series of 'vmstat' outputs, we need to run the following command:

为了获得一系列的'vmstat'输出,我们需要运行以下命令:


vmstat <DELAY> <ITERATIONS>
Vmstat Continuous
Series of ‘vmstat’ outputs
一系列的“ 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
Vmstat Memory Stats
Vmstat Memory Stats
Vmstat内存统计信息

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
Vmstat Disk
Disk statistics using ‘vmstat’
使用'vmstat'的磁盘统计信息

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 been implemented incorrectly.

注意:在某些版本的'vmstat' ,上面输出中的最后两个条目是 实施不正确。

For detailed statistics on each disk usage, we can use '-d' option.

有关每个磁盘使用情况的详细统计信息,我们可以使用'-d'选项。


vmstat -d
Vmstat Disk Detailed
Detailed disk statistics
详细的磁盘统计信息

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.

Linux内核实现了平板级的内存管理,以有效使用系统中的内存。 vmstat命令提供与Linux内核维护的平板有关的信息。

This sort of output can be obtained by:

可以通过以下方式获得此类输出:


vmstat -m
Vmstat Slab Info
Slabs in Memory Management
内存管理板

The columns in the output means:

输出中的列表示:

  • The first column denotes the name of the slab (Cache).

    第一列表示平板名称 (缓存)。
  • It is followed by the number of objects currently held 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.

总结了Linux中'vmstat'命令用法的指南。 如果您对命令的某些说明感到好奇,那么手册页将是正确的选择。

The manual pages can be accessed by running 'man vmstat' on the terminal. We hope this article provided enough information to the reader.

可以通过在终端上运行'man vmstat'来访问手册页。 我们希望本文能为读者提供足够的信息。

翻译自: https://www.journaldev.com/42125/vmstat-command-in-linux

linux vmstat

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值