当前位置: 主页 > 操作系统 > Linux > Linux中vmstat工具的使用

Linux中vmstat工具的使用

时间:2010-7-26来源:互联网 点击:

  vmstat 工具提供了一种低开销的系统性能观察方式.因为 vmstat 本身就是低开销工具,在非常高负荷的服务器上,你需要查看并监控系统的健康情况,在控制窗口还是能够使用vmstat 输出结果.这个工具运行在2种模式下:average 和 sample 模式.sample 模式通过指定间隔时间测量状态值.这个模式对于理解在持续负荷下的性能表现,很有帮助.下面就是

  vmstat 运行1秒间隔的示例:

  # vmstat 1

  procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----

  r b swpd free buff cache si so bi bo in cs us sy id wa

  0 0 104300 16800 95328 72200 0 0 5 26 7 14 4 1 95 0

  0 0 104300 16800 95328 72200 0 0 0 24 1021 64 1 1 98 0

  0 0 104300 16800 95328 72200 0 0 0 0 1009 59 1 1 98 0

  Table 1: The vmstat CPU statistics

  Field Description

  r The amount of threads in the run queue. These are threads that are runnable, but the CPU is not available to execute them.

  当前运行队列中线程的数目.代表线程处于可运行状态,但CPU 还未能执行.

  b This is the number of processes blocked and waiting on IO requests to finish.

  当前进程阻塞并等待IO 请求完成的数目

  in This is the number of interrupts being processed.

  当前中断被处理的数目

  cs This is the number of context switches currently happening on the system.

  当前kernel system中,发生上下文切换的数目

  us This is the percentage of user CPU utilization.

  CPU 利用率的百分比

  sys This is the percentage of kernel and interrupts utilization.

  内核和中断利用率的百分比

  wa This is the percentage of idle processor time due to the fact that ALL runnable threads are blocked waiting on IO.

  所有可运行状态线程被阻塞在等待IO 请求的百分比

  id This is the percentage of time that the CPU is completely idle.

  CPU 空闲时间的百分比

  案例学习:持续的CPU 利用率

  在这个例子中,这个系统被充分利用

  # vmstat 1

  procs memory swap io system cpu

  r b swpd free buff cache si so bi bo in cs us sy wa id

  3 0 206564 15092 80336 176080 0 0 0 0 718 26 81 19 0 0

  2 0 206564 14772 80336 176120 0 0 0 0 758 23 96 4 0 0

  1 0 206564 14208 80336 176136 0 0 0 0 820 20 96 4 0 0

  1 0 206956 13884 79180 175964 0 412 0 2680 1008 80 93 7 0 0

  2 0 207348 14448 78800 175576 0 412 0 412 763 70 84 16 0 0

  2 0 207348 15756 78800 175424 0 0 0 0 874 25 89 11 0 0

  1 0 207348 16368 78800 175596 0 0 0 0 940 24 86 14 0 0

  1 0 207348 16600 78800 175604 0 0 0 0 929 27 95 3 0 2

  3 0 207348 16976 78548 175876 0 0 0 2508 969 35 93 7 0 0

  4 0 207348 16216 78548 175704 0 0 0 0 874 36 93 6 0 1

  4 0 207348 16424 78548 175776 0 0 0 0 850 26 77 23 0 0

  2 0 207348 17496 78556 175840 0 0 0 0 736 23 83 17 0 0

  0 0 207348 17680 78556 175868 0 0 0 0 861 21 91 8 0 1

  根据观察值,我们可以得到以下结论:

  1,有大量的中断(in) 和较少的上下文切换(cs).这意味着一个单一的进程在产生对硬件设备的请求.

  2,进一步显示某单个应用,user time(us) 经常在85%或者更多.考虑到较少的上下文切换,这个应用应该还在处理器中被处理.

  3,运行队列还在可接受的性能范围内,其中有2个地方,是超出了允许限制.

  4.3 案例学习:超负荷调度

  在这个例子中,内核调度中的上下文切换处于饱和

  # vmstat 1

  procs memory swap io system cpu

  r b swpd free buff cache si so bi bo in cs us sy wa id

  2 1 207740 98476 81344 180972 0 0 2496 0 900 2883 4 12 57 27

  0 1 207740 96448 83304 180984 0 0 1968 328 810 2559 8 9 83 0

  0 1 207740 94404 85348 180984 0 0 2044 0 829 2879 9 6 78 7

  0 1 207740 92576 87176 180984 0 0 1828 0 689 2088 3 9 78 10

  2 0 207740 91300 88452 180984 0 0 1276 0 565 2182 7 6 83 4

  3 1 207740 90124 89628 180984 0 0 1176 0 551 2219 2 7 91 0

  4 2 207740 89240 90512 180984 0 0 880 520 443 907 22 10 67 0

  5 3 207740 88056 91680 180984 0 0 1168 0 628 1248 12 11 77 0

  4 2 207740 86852 92880 180984 0 0 1200 0 654 1505 6 7 87 0

  6 1 207740 85736 93996 180984 0 0 1116 0 526 1512 5 10 85 0

  0 1 207740 84844 94888 180984 0 0 892 0 438 1556 6 4 90 0

  根据观察值,我们可以得到以下结论:

  1,上下文切换数目高于中断数目,说明kernel中相当数量的时间都开销在上下文切换线程.

  2,大量的上下文切换将导致CPU 利用率分类不均衡.很明显实际上等待io 请求的百分比(wa)非常高,以及user time百分比非常低(us).

  3,因为CPU 都阻塞在IO请求上,所以运行队列里也有相当数目的可运行状态线程在等待执行.

站长资讯网
. TAG: Linux vmstat
推荐内容最近更新人气排行
关于我们 | 友情链接 | 网址推荐 | 常用资讯 | 网站地图 | RSS | 留言