vmstat:Linux系统性能分析监控工具

一. Ubuntu 14.04的man vmstat 描述:

NAME vmstat - Report virtual memory statistics(报告虚拟内存统计信息) SYNOPSIS vmstat [options] [delay [count]]

二. 常用法:
1). vmstat [delay] [count]
例如:vmstat 2 2表示监测间隔为2s, 监测次数为2次.
2). vmstat [delay]
例如:vmstat 2 表示间隔2s, 一直监测到结束vmstat.
输出格式为:

vmstat 2 4

三. 各个输出项解释:
Procs
r: The number of runnable processes (running or waiting for run time).
 可运行进程的数目(正在运行或等待运行)[也就是在就绪队列和运行队列中的进程?]
 当这个值超过了CPU数目,就会出现CPU瓶颈了。
b: The number of processes in uninterruptible sleep.
 处于"不可中断睡眠状态"的进程数目.
 [可中断睡眠:可以用信号唤醒]
 [不可中断睡眠:不接受外来信号(异步信号).一般由IO引起,同步IO在做读或写操作时,cpu不能做其它事情,只能等待,这时进程处于这种状态,如果程序采用异步IO,这种状态应该很少见]

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)
   非活动的内存(-a选项)
active: the amount of active memory. (-a option)
   活动的内存(-a选项)
Swap
si: Amount of memory swapped in from disk (/s).
   每秒从磁盘读入虚拟内存的大小,如果这个值大于0,表示物理内存不够用或者内存泄露了.
so: Amount of memory swapped to disk (/s).
   每秒虚拟内存写入磁盘的大小,如果这个值大于0,表示物理内存不够用或者内存泄露了.
IO
bi: Blocks received from a block device (blocks/s).
   每秒从块设备接收到的块数量(读块设备),这里的块设备是指系统上所有的磁盘和其他块设备,默认块大小是1024byte.
bo: Blocks sent to a block device (blocks/s).
   每秒向块设备发送的块数量(写块设备),例如读取文件,bo就要大于0。bi和bo一般都要接近0,不然就是IO过于频繁,需要调整.
System
in: The number of interrupts per second, including the clock.
   每秒钟中断次数,包括时钟中断.
cs: The number of context switches per second.
   每秒上下文切换次数,例如我们调用系统函数,就要进行上下文切换,线程的切换,也要进程上下文切换,这个值要越小越好.上下文切换会影响CPU的利用率.
CPU
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
   用户CPU时间,非内核代码运行时间.
sy: Time spent running kernel code. (system time)
   系统CPU时间,内核代码运行时间.
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
   空闲CPU时间.(在linux 2.5.41之前包括IO等待时间.)
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
   等待IO的时间.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

补充:

R (TASK_RUNNING),可执行状态。 S (TASK_INTERRUPTIBLE),可中断的睡眠状态。 D (TASK_UNINTERRUPTIBLE),不可中断的睡眠状态。   一般由IO引起,同步IO在做读或写操作时,cpu不能做其它事情,只能等待,这时进程处于这种状态,如果程序采用异步IO,这种状态应该很少见. T (TASK_STOPPED or TASK_TRACED),暂停状态或跟踪状态。 Z (TASK_DEAD – EXIT_ZOMBIE),退出状态,进程成为僵尸进程。 X (TASK_DEAD – EXIT_DEAD),退出状态,进程即将被销毁。 O:进程正在处理器运行. I:空闲状态(idle) B:进程正在等待更多的内存页

四.vmstat的选项

-a, --active Display active and inactive memory, given a 2.5.41 kernel or better. -f, --forks The -f switch displays the number of forks since boot. This includes the fork, vfork, and clone system calls, and is equivalent to the total number of tasks created. Each process is represented by one or more tasks, depending on thread usage. This display does not repeat. -m, --slabs Displays slabinfo. -n, --one-header Display the header only once rather than periodically. -s, --stats Displays a table of various event counters and memory statistics. This display does not repeat. -d, --disk Report disk statistics (2.5.70 or above required). -D, --disk-sum Report some summary statistics about disk activity. -p, --partition device Detailed statistics about partition (2.5.70 or above required). -S, --unit character Switches outputs between 1000 (k), 1024 (K), 1000000 (m), or 1048576 (M) bytes. Note this does not change the swap (si/so) or block(bi/bo) fields.

如何通过阅读源代码了解 vmstat 中的指标 

Linux vmstat 命令详解

Linux下vmstat 显示结果详解

Linux监控工具之vmstat 详解

Linux vmstat命令实战详解

Linux vmstat监控系统负载

vmstat命令详解——Linux性能分析

Linux vmstat 命令参数详解 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/14227.html