Reading vmstat in linux – Part 1

Linux comes with many tools to enable administrators to evaluate the performance of a system. One of these very useful tools is vmstat. Vmstat is available on most unix distributions and is included by default on many modern Linux distributions. As with most Linux commands, built in help is available via the commandman vmstat.

First we will review what the different columns means and then we will review the output that would be consistent with a few common bottlenecks.

Sample vmstat output:

procs      ———–memory———-             —swap–       —–io—- –system–              —–cpu——
r  b        swpd   free   buff  cache                   si   so          bi    bo   in   cs               us sy id wa st
1  1       5888 140136 167700 1506440        0    0          10     2    0    0                   6  2 90  3  0
0  1       5888 147864 167724 1507492        0    0       1164   340 2092 4506          8  3 76 13  0
0  1       5888 147220 167760 1508584        0    0       1240   212 2059 2539          2  1 84 13  0

Procs

r: The number of processes waiting for run time.
b: The number of processes in uninterruptible sleep.

Uninterruptible sleep usually represents processes that are waiting on input to be processed.  This could either be because it is waiting for user input or disk i/o operations to complete.

Memory

swpd: the amount of virtual memory used.
free: the amount of idle memory.
buff: the amount of memory used as buffers.
cache: the amount of memory used as cache.
inact: the amount of inactive memory. (-a option)
active: the amount of active memory. (-a option)

Swap

si: Amount of memory swapped in from disk (/s).
so: Amount of memory swapped to disk (/s).

IO

bi: Blocks received from a block device (blocks/s).
bo: Blocks sent to a block device (blocks/s).

System

in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.

CPU

These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

In the second part of this series, we are going to target 3 different types of potential bottlenecks that a system might suffer from.  Specifically these are:

  • IO Bound
  • CPU Bound
  • Memory Bound

Most performance problems can be placed into one of these categories.  By using what we learned inPart 1, we can use the information from vmstat to provide more information about what aspect of a system is limiting it from handling a greater load….and therefore what should be upgraded to provided greater capacity.

IO Bound System

An IO bound system is a machine that is usually suffering from performance limitations due to disk speed.  While there are other types of IO a server could be waiting on, usually it is disk and disk speed that are the problems.  This can be culled from reviewing vmstat by looking at both the uninterruptable sleep column (bcolumn) and a high value in thewacolumn.    An example from vmstate would look as follows:

#vmstat 5

procs      ———–memory———-             —swap–       —–io—- –system–                          —–cpu——
r  b        swpd   free   buff  cache                   si   so          bi    bo   in   cs                             us sy id wa st

1  8      5888 140136 167700 1506440        0    0        6783 17333  1738  16648                   6  2 9  83  0
1  6      5888 140136 167700 1506440        0    0        6885 18353  1831  18658                   8  4 9  77  0
1  6      5888 140136 167700 1506440        0    0        6482 12323  1534  17632                   16  12 9  63  0

In the above, you can clearly see both issues at work as predicted above.  Thewais quite high 63-83 and the number of processes in uninterpretable sleep is between 6 and 8.

Memory Bound – Swapping

The second type of system we will look at is a system that is attempting to allocate more memory than physically exists in the system.  It is normal for a linux/unix system to use swap to augment its available memory.   As such, any system can show some amount of memory allocated to swap.  However, this only becomes a problem when the system starts waiting for memory to be paged in and out of swap to satisfy its processes.  From a vmstat perspective, this would appear in 2 ways.  First is theswpdcolumn.  However, the presence of large values in theswpdcolumn does not, in and of itself, constitute swapping.  The more important demonstration of this is high values insiandsocolumns.  Here is a sample vmstat that shows some swapping.

#vmstat 5

procs      ———–memory———-                   —swap–       —–io—- –system–              —–cpu——

r  b        swpd   free   buff  cache                    si           so          bi    bo   in   cs               us sy id wa st
1  18   3794291 140136 167700 1506440     19851    9780        16783 27333  1738  1648        6    2 29  63  0
1  16   3797936 140136 167700 1506440     15913  30807        38353 28331  1658  3342        8  14 19  57  0
1  10   3847364 140136 167700 1506440     18334  22355        26482 32323  1534  1732      16  12 29  33  0

CPU Bound Machine

The last type of system we will review is a CPU-Bound machine.  A server that is experiencing this problem simply does not have enough processing power to properly perform its operations.  Usually this system will show a high number in theuscolumn.  Again, remember the us column showsusthe amount of time spent processing non-kernel code.  It is also quite normal in this scenario to have a larger number in thercolumn as they are queued up waiting for cpu time.

procs ———–memory———-      —swap–      —–io—-      –system–      —-cpu—-
r  b   swpd   free   buff  cache   si   so         bi    bo        in    cs      us sy id wa
5  1    648 755300  31460 2095012         0    0         76  3458 2013  1369      95  5  0  0
5  0    648 741196  31568 2103336         0    0         24  1852 2063  1481      88 12  0  0
8  0    648 706828  31616 2115936         0    0         50  2590 2118  1609      90 10  0  0
14  0    648 700628  31664 2133024       0    0       117  4320 2138  1290      90 10  0  0

Reading vmstat in linux – Part 1,布布扣,bubuko.com

时间: 2024-11-10 14:13:19

Reading vmstat in linux – Part 1的相关文章

vmstat命令--Linux命令应用大词典729个命令解读

内容来源于人民邮电出版社<Linux命令应用大词典> 讲述729个命令,1935个例子 学习Linux系统的参考书.案头书,遇到不懂的命令或命令选项一查即可 争取每天都发布内容 本文出自 "airfish2000" 博客,更多命令查看博客: http://airfish2000.blog.51cto.com/10829608/1894368 vmstat命令 使用vmstat命令可以对操作系统的虚拟内存.进程.分页.块I/O和CPU活动等进行监控.它是对系统的整体情况进行统

性能测试中vmstat命令的常见使用。

vmstat是Linux中常用的一个命令,尤其是在进行性能测试时,使用该命令,往往能辅助我们进行性能问题定位. 我们先看一下这个命令执行得到的数据. [[email protected] ~]# vmstat 1 10procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0

linux系统中常见的性能分析工具

一.vmstat vmstat是linux/unix上一个监控工具,能展示给定时间间隔的服务器的状态,包括操作系统的内存信息,CPU使用状态.进程信息等. 语法: vmstat [-V] [delay [count]]     #-V     打印出vmstat工具的版本信息     #delay  设置两次输出的时间间隔     #count  设置总共输出的次数 对输出参数进行讲解 procs r:运行进程数(即真正分配到cpu的进程数量),如果该值长期大于系统逻辑cpu的数量,表示cpu不

超实用的8个Linux命令行性能监测工具

对每个系统/网络管理员来说,每天监测Linux系统性能是一项非常艰巨的任务.在IT业从事5年的Linux系统管理员后,我发现监控和保持系统正常运行真不是件容易的事,为此,我总结了8个非常实用的命令行工具给Linux/Unix系统管理员.这些命令支持所有的Linux系统,不仅可以用于监控系统,还可以发现导致性能问题的原因所在.下面提供的8个命令足够你选择其中一个用于你的场景中. 1.TOP——Linux进程监控 Linux的top命令是一个性能监视程序,许多Linux系统管理员经常使用它来监测系统

linux 系统监控、诊断工具之 IO wait

1.问题: 最近在做日志的实时同步,上线之前是做过单份线上日志压力测试的,消息队列和客户端.本机都没问题,但是没想到上了第二份日志之后,问题来了: 集群中的某台机器 top 看到负载巨高,集群中的机器硬件配置一样,部署的软件都一样,却单单这一台负载有问题,初步猜测可能硬件有问题了. 同时,我们还需要把负载有异常的罪魁祸首揪出来,到时候从软件.硬件层面分别寻找解决方案. 2.排查: 从 top 中可以看到 load average 偏高,%wa 偏高,%us 很低: 充分说明这个问题是由于 IO

[转]linux 系统监控、诊断工具之 IO wait

1.问题: 最近在做日志的实时同步,上线之前是做过单份线上日志压力测试的,消息队列和客户端.本机都没问题,但是没想到上了第二份日志之后,问题来了: 集群中的某台机器 top 看到负载巨高,集群中的机器硬件配置一样,部署的软件都一样,却单单这一台负载有问题,初步猜测可能硬件有问题了. 同时,我们还需要把负载有异常的罪魁祸首揪出来,到时候从软件.硬件层面分别寻找解决方案. 2.排查: 从 top 中可以看到 load average 偏高,%wa 很高,%us 偏低: 从上图我们大致可以推断 IO

Linux进程管理及进程管理工具的使用

Linux的进程管理 进程:简单来说就是一个运行中的程序的副本,是进程的一个实例,它是有生命周期的 进程的创建:进程都是由其父进程创建的,最开始的进程就是init. 进程优先级:0-139 实时优先级:1-99: 静态优先级:100-139,对于静态来说数字越小优先级越高, 优先级还有一个Nice值,值为-20(对应100),19(对应19),可以通过调整Nice值来调整优先级. 进程分为守护进程和前台进程,守护进程就是在系统引导过程中启动的进程,跟终端无关的进程:前台进程跟终端有关,通过终端启

全面了解linux情况常用命令

查看linux服务器CPU详细情况1. 显示CPU个数命令 # cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l 1 2. 显示每个物理cpu中core的个数 # cat /proc/cpuinfo |grep "cpu cores" | uniq cpu cores : 2 3. 显示逻辑cpu个数命令 # cat /proc/cpuinfo |grep "processor&quo

进程管理,及性能监控 ps, pstree, pidof, top, htop, pmap, vmstat, dstat

进程的分类:    CPU-Bound: CPU密集型    I/O-Bound: I/O密集型 进程的分类:    批处理进程    交互式进程    实时进程 进程调度器:    进程优先级:0-139        实时优先级:1-99,数字越大,优先级越高        静态优先级:100-139, nice值调整,数字越大,优先级越低            nice:     -20, 19            priority: 100, 139        动态优先级:由内核维