linux vmstat_如何使用vmstat监视Linux性能

linux vmstat

linux vmstat

Linux distributions provides a lot of tools in order to monitor system performance. vmstat is one of the most used tool for system performance monitoring. vmstat can collect and report information about memory, cpu, swap, io in a detailed way. In this tutorial we will examine the output of the vmstat and different features and options of it.

Linux发行版提供了许多工具来监视系统性能。 vmstat是用于系统性能监视的最常用的工具之一。 vmstat可以详细收集和报告有关内存,cpu,swap,io的信息。 在本教程中,我们将检查vmstat的输出以及它的不同功能和选项。

列出系统资源使用情况 (List System Resource Usage)

We will start by using vmstat command without any option. This will list general statistics and information about system resource usage.

我们将首先使用不带任何选项的vmstat命令。 这将列出常规统计信息和有关系统资源使用情况的信息。

$ vmstat
List System Resource Usage
List System Resource Usage
列出系统资源使用情况

We can see that there is 5 main column.

我们可以看到有5个主要列。

  • procs display information about processes.

    procs显示有关进程的信息。

  • memory display information about memory metrics

    memory显示有关内存指标的信息

    • swpd provides avaible swap size

      swpd提供可用的交换大小

    • free provides unused memory size

      free提供未使用的内存大小

    • buff provides buffered memory size

      buff提供缓冲的内存大小

    • cache provides cached memory size

      cache提供缓存的内存大小

    memory display information about memory metrics

    memory显示有关内存指标的信息

  • swap provides swap related information but in these days it is not used so much.

    swap提供了与交换有关的信息,但是在最近的日子里,它使用的很少。

  • io provides disk related informatin

    io提供磁盘相关信息

    • bi block input shows data block count read from block devices

      bi块输入显示从块设备读取的数据块计数

    • bo block output shows block count sent to block devices

      bo块输出显示发送到块设备的块计数

    io provides disk related informatin

    io提供磁盘相关信息

  • system provides interrup and context switch information which is related with CPU

    system提供与CPU相关的中断和上下文切换信息

    • in number of interrupts per second

      in每秒的中断数

    • cs number of context switches per second

      cs上下文的数目每秒切换

    system provides interrup and context switch information which is related with CPU

    system提供与CPU相关的中断和上下文切换信息

  • cpu provides CPU usage information

    cpu提供CPU使用率信息

    • us time spent user space operations or user time

      us花费在用户空间操作或用户时间上的时间

    • id time spent idle

      id时间花在闲置

    • sy time spent system operations

      sy运行所花的时间

    • wa time spent waiting for IO.

      wa时间花在等待IO。

    • st time spent from virtual machine

      st时间从虚拟机花

    cpu provides CPU usage information

    cpu提供CPU使用率信息

以指定间隔交互式打印输出(Print Output At Specified Interval Interactively)

By default vmstat command is non interactive. It will print information just one time after called and then quit. If we need to it continuously and print command output at given intervals we need to provide the interval as seconds after command. We will print at 5 second interval in this example.

默认情况下, vmstat命令是非交互式的。 它将在调用后仅一次打印信息,然后退出。 如果我们连续需要它并以给定的间隔打印命令输出,则需要以命令后的秒数作为间隔。 在此示例中,我们将以5秒的间隔打印。

$ vmstat 5
Print Output At Specified Interval Interactively
Print Output At Specified Interval Interactively
以指定间隔交互式打印输出

打印时间戳(Print Timestamp)

As the output printed one or multiple times we may need to know related time. We can print given information time by printing time stamp. We need to provide -t option for this. Time column will be added as last column after cpu column.

当输出打印一次或多次时,我们可能需要知道相关时间。 我们可以通过打印时间戳来打印给定的信息时间。 我们需要为此提供-t选项。 时间列将添加为cpu列之后的最后一列。

$ vmstat -t
Print Timestamp
Print Timestamp
打印时间戳

列出内存活动和不活动(List Memory Active and Inactive)

Active memory is part or size of the memory which is actively used currently running processes. Inactive memory is part or size of the memory where died or non existing processes. We will use -a option for active and inactive memory. We can see that memory column provides inact and active columns.

活动内存是当前正在运行的进程正在使用的内存的一部分或大小。 不活动的内存是已死亡或不存在进程的内存的一部分或大小。 我们将-a选项用于活动和非活动内存。 我们可以看到memory列提供了inactactive列。

$ vmstat -a
List Memory Active and Inactive
List Memory Active and Inactive
列出内存活动和非活动

详细查看磁盘I / O静态信息(View Disk I/O Statics In Detail)

As writing disk and disk topology is a complex area related information can be printed with the -d option. Following information will be provided by this option.

由于写入磁盘和磁盘拓扑是一个复杂区域,因此可以使用-d选项打印相关信息。 此选项将提供以下信息。

$ vmstat -d
View Disk I/O Statics In Detail
View Disk I/O Statics In Detail
详细查看磁盘I / O静态信息
  • Reads show read related information

    Reads显示阅读的相关信息

    • total shows successfully completed total read

      total显示成功完成的总数读取

    • merged shows grouped reads

      merged显示分组阅读

    • sectors shows sector reads

      sectors显示部门读取

    • ms shows milliseconds spent for reads

      ms显示读取花费的毫秒数

    Reads show read related information

    Reads显示阅读的相关信息

  • Writes show write related information

    Writes显示写相关信息

    • total shows successfully completed total read

      total显示成功完成的总数读取

    • merged shows grouped reads

      merged显示分组阅读

    • sectors shows sector reads

      sectors显示扇区读取

    • ms shows milliseconds spent for reads

      ms显示读取花费的毫秒数

    Writes show write related information

    Writes显示写相关信息

  • IO show currently active IO operations information

    IO显示当前活动的IO操作信息

    • cur I/O in progress

      cur正在进行I / O

    • s seconds spent for I/O

      I / O花费的s

    IO show currently active IO operations information

    IO显示当前活动的IO操作信息

LEARN MORE  How To Get Ram Information In Linux?
了解更多如何在Linux中获取Ram信息?

查看磁盘I / O静态摘要 (View Disk I/O Statics Summary)

We can also print disk related I/O statistics in summary or brief mode with -D option.

我们还可以使用-D选项以摘要或简要模式打印与磁盘相关的I / O统计信息。

$ vmstat -D
View Disk I/O Statics Summary
View Disk I/O Statics Summary
查看磁盘I / O静态摘要

用法兆字节(公制)(Usage Megabyte As Metric)

During usage of all options the default metric for memory is byte. This will lower readability. We can make metrics more readable or human readable with -S M option which will set Megabyte as metric.

在使用所有选项期间,默认的内存度量标准是字节。 这将降低可读性。 我们可以使用-SM选项使指标更易读或更易读,从而将兆字节设置为指标。

$ vmstat -S M
Usage Megabyte As Metric
Usage Megabyte As Metric
用法兆字节(公制)

列出事件计数器和内存静态信息 (List Event Counters and Memory Statics)

We can use -s option in order to print event counters and memory statistics.

我们可以使用-s选项来打印事件计数器和内存统计信息。

$ vmstat -s
List Event Counters and Memory Statics
List Event Counters and Memory Statics
列出事件计数器和内存静态信息

翻译自: https://www.poftut.com/how-to-use-vmstat-to-monitor-linux-performance/

linux vmstat

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值