您的位置:首页 > 其它

VMSTAT命令常用功能说明

2015-07-06 06:53 453 查看
一.命令说明

vmstat用于报告系统的虚拟内存使用情况,信息包含进程、内存、交换页、block IO、中断、CPU活动等。第一行表示自上次重启以来的平均值,如果不不指定delay和count的话就是自上次启动来的平均值。以下从查看虚拟内存的统计信息和磁盘情况的两个层面进行查看

二.分层面查看信息
2.1.虚拟内存层面

从虚拟内存层面使用vmstat主要查看进程情况等,语法及案例如下:
vmstat [option] [delay [count]]

-a 显示active/inactive内存信息;
-t 在每行记录的末端添加时间戳
-n 控制表头仅显示一次,未指定会周期性显示;

样例说明:

[root@node110 net]# vmstat -a -t 1 3 显示时间戳/活动内存
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ ---timestamp---
r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st
0  0      0 369488 756084 765868    0    0    14     6   97  182  0  0 98  1  0     2014-11-23 08:09:34 CST
0  0      0 369488 756092 765912    0    0     0    12  851 1653  1  0 96  3  0     2014-11-23 08:09:35 CST
0  0      0 369488 756092 765912    0    0     0    28  843 1670  2  1 92  5  0     2014-11-23 08:09:36 CST

[root@node110 net]# vmstat -n 1 3 使用-n选项控制表头不周期性输出
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
0  0      0 377084 108052 1206620    0    0    15     6   93  174  0  0 98  1  0    
0  0      0 377076 108052 1206624    0    0     0    16  879 1685  1  1 98  0  0    
0  0      0 377076 108052 1206628    0    0     4     8  880 1742  2  0 94  4  0     

Procs

    r: (执行队列长度)需要执行的进程数,如果此值大于cpu个数的3-5倍则CPU资源欠缺

    b: (阻塞队列长度)等待非CPU资源的队列长度,可能是磁盘/网络的IO引起的

Memory

    swpd: 交换空间使用量(KB)

    free: 空闲内存量(KB)

    buff: buffer大小(KB)

    cache: cache大小(KB)

    注:以下两个选项必须指定-a

    inact: 可供分配的内存

    active: 不能被重新分配的内存大小

Swap

    si: 每秒从swap换入内存的数据量(KB),长期大量换入需要考虑增加内存

    so: 每秒从内存换出到swap的数据量(KB),长期大量换出需要考虑增加内存

IO

    bi: 每秒从块设备加载到内存的块数,swap的换入会影响此值;

    bo: 每秒从内存换出到块设备的块数,swap的换出会影响此值

System

    in: interrupt次数,包括时钟中断。大量的时钟中断可能会IO问题

    cs: 每秒的上下文切换次数

CPU

    CPU的使用率

    us: 用户进程使用CPU的占比

    sy: 系统进程使用的CPU占比

    id: 空闲的CPU占比

    wa: CPU等待IO的时间,如果长期出现大量等待需要分析是否有IO瓶颈

    st: 虚拟机占用的资源

2.2.查看磁盘统计信息

vmstat也可以查看磁盘分区的相关统计信息,主要从分区层面和磁盘层面,语法分别如下:
分区层面(仅针对partition):

vmstat [option] -p <partition> [delay [ count]] 查看某个分区的详细统计信息

 -n 不周期性输出表头

范例:

[root@node110 net]# vmstat -p /dev/sda1 1 3

sda1          reads   read sectors  writes    requested writes

                 807       6514          3         24

                 807       6514          3         24

                 807       6514          3         24

reads: Total number of reads issued to this partition
read sectors: Total read sectors for partition
writes : Total number of writes issued to this partition
requested writes: Total number of write requests made for partition

磁盘层面:

vmstat -d [-n]  [delay [ count]] 查看磁盘的IO情况

范例

[root@node110 net]# vmstat -d 1 3

disk- ------------reads------------ ------------writes----------- -----IO------

       total merged sectors      ms  total merged sectors      ms    cur    sec

ram0       0      0       0       0      0      0       0       0      0      0

ram1       0      0       0       0      0      0       0       0      0      0

ram2       0      0       0       0      0      0       0       0      0      0

.

.

.

sda    34334  11658 1825892  613266 112306 155758 1860744 2866283      0   2012

sdb      636   1137    3738    4613      0      0       0       0      0      4

sdc     2731   8167   87632    7572    335   8880   73560   39469      0     12

sdd     2997   8160   89728    5652    295   8924   73592   61275      0     11

sde     2518   8177   86032    4278    282   8867   73032   78144      0     10

sdf      373     14    3096    1901      0      0       0       0      0      1

sdg      556     14    4560      83      0      0       0       0      0      0

dm-0     110      0     880      15      1      0       8       0      0      0

dm-1   28763      0  230080   59726  27361      0  218792 16588147      0     12

reads:

total: Total reads completed successfully
merged: grouped reads (resulting in one I/O)
sectors: Sectors read successfully
ms: milliseconds spent reading

writes:

total: Total writes completed successfully
merged: grouped writes (resulting in one I/O)
sectors: Sectors written successfully
ms: milliseconds spent writing

IO:

cur: I/O in progress
sec: seconds spent for I/O
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: