10.6 linux下常见的性能分析工具
10.6.1 vmstat
虚拟内存统计。
vmstat [-V] [-n] [delay [count] ]
各个选项及参数意义如下:
-V 打印版本
-n周期性循环输出时,输出的头部信息仅显示一次
delay 表示两次输出之间的时间间隔(秒)
count 按照delay指定的时间间隔统计的次数,默认为连续输出不间断
例如:
vmstat 1
表示每3秒更新一次输出信息,循环输出,ctrl+c停止输出
vmstat 3 5
表示每3秒更新一次输出信息,统计5次后停止
下面是vmstat命令在某个系统的输出结果:
$ vmstat 2 3
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
4 0 119736 3520744 477816 10162532 0 0 2 20 0 0 3 1 96 0
4 0 119736 3520416 477816 10162532 0 0 4 132 2449 64597 15 10 75 0
8 0 119736 3520968 477816 10162532 0 0 0 0 2411 63536 16 10 75 0
Procs r: The number of processes waiting for run time. b: The number of processes in uninterruptible sleep. 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, shown as zero.