linux常用系统监控工具之vmstat,vmstat是Virtual Meomory Statistics(虚拟内存统计)的缩写,可对os的processes、内存、分页、块的I/O、traps、CPU活动进行监控。详细信息请品读vmstat的帮助文档。
vmstat语法结构:
为了统计的准确,多采集几组数据:
[root@Jacson ~]# vmstat 3 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 0 0 485920 41340 419984 0 0 65 8 437 40 1 19 80 1 0
0 0 0 485920 41356 419988 0 0 0 9 835 56 0 18 82 0 0
0 0 0 485920 41380 419980 0 0 0 17 780 47 0 18 82 0 0
0 0 0 485920 41380 419988 0 0 0 0 792 43 0 22 78 0 0
0 0 0 485920 41396 419988 0 0 0 17 831 46 0 18 82 0 0
对上面的输出做一下解释:
proces:
r: The number of processes waiting for run time.这个值长期大于系统CPU的个数,说明CPU不足,需要增加CPU
b: The number of processes in uninterruptible sleep.等待的内容可能为I/O说着内存交换
Memory
swpd: the amount of virtual memory used.(以KB为单位)
free: the amount of idle memory.(以KB为单位)
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).
在一般情况下si/so的值都为0,如果长期不为0,那么在oracle应用下最好先查看内存分配/参数,其他应用估计要增加内存
IO
bi: Blocks received from a block device (blocks/s).(单位是KB/S)
bo: Blocks sent to a block device (blocks/s).(单位是KB/S)
在知道系统I/O带宽的情况下,bi+bo如果大于I/O带宽且wa(wait)值比较大,则表示系统I/O真的有问题,估计是要采取措施了
System
in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.
上面2个值越大,表示由内核消耗的CPU时间越多。
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.
1.给据实际经验:us+sy的最大参考值为85%,如果us+sy大于85%,说明目前系统CPU资源很紧张。
wa的参考值为30%,(根据硬件RAID的读写分配比例)如果大于最小的分配值,说明等待严重。一般情况下引起I/O较高的操作都是大量的随机读写引起的,比如(select * from table)
综上所述,再对CPU做资源评估时结合proces的r列的值和CPU项中的us+sy和id列的值,做综合评比!