vmstat报告虚拟内存的统计信息,用来向用户提供分析系统瓶颈问题的信息。
Usage:
vmstat [选项] [统计间隔 [次数]]
选项:
-a, --active active/inactive memory
-f, --forks number of forks since boot
-m, --slabs slabinfo
-n, --one-header do not redisplay header
-s, --stats event counter statistics
-d, --disk disk statistics
-D, --disk-sum summarize disk statistics
-p, --partition <dev> partition specific statistics
-S, --unit define display unit
-w, --wide wide output
-t, --timestamp show timestamp
“统计间隔”是以秒为单位的刷新时间间隔。如果没有给出此时间,则显示系统启动至今的平均值。
“次数”指的是更新的次数。 如果没有指定此数而又定义了统计间隔,则默认无穷次。
示例:
# 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
2 0 264 82688 172 297208 0 0 63 10 50 112 0 1 99 0 0
0 0 264 82688 172 297208 0 0 0 0 45 79 1 0 99 0 0
0 0 264 82688 172 297208 0 0 0 0 32 70 0 0 100 0 0
0 0 264 82688 172 297208 0 0 0 0 34 69 0 0 100 0 0
0 0 264 82688 172 297208 0 0 0 0 41 77 0 0 99 0 0
第一行显示了计算机自上次重启至今的平均使用情况。后面的每一行信息是按“统计间隔”定期地显示系统的各部分信息。进程信息和内存信息都是即时产生的。
每10秒更新一次统计信息,以兆字节为单位显示内存和交换统计信息:
vmstat 10 -S M
请注意,-S选项不影响IO块统计信息。IO部分信息始终以块的形式显示。
# vmstat 3 5 -S M -a
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free inact active si so bi bo in cs us sy id wa st
2 0 0 81 161 465 0 0 63 10 50 112 0 1 99 0 0
0 0 0 80 161 465 0 0 0 0 34 73 0 0 100 0 0
0 0 0 80 161 465 0 0 0 0 35 75 0 0 100 0 0
0 0 0 80 161 465 0 0 0 0 32 70 0 0 100 0 0
0 0 0 80 161 465 0 0 0 0 31 70 0 0 100 0 0
为特定类型的内核数据对象分配、使用的内存可以重新用于相同类型的另一个数据对象,无需释放和重新分配内存。可以将slab看作是预先分配的、可测量的、满足内核自身需求的RAM段。
要查看slab的统计信息,请使用 -m 选项。由于输出可能相当长,可以通过管道将结果传递给less。
vmstat -m | less
输出有5列:
Cache:缓存的名称。
num:此缓存中当前活动对象的数量。
total:此缓存中可用对象的总数。
size:缓存中每个对象的大小。
pages:代表内存页总数,每个内存页中至少具有一个与此缓存关联的对象。
vmstat -d | less
对于每个磁盘,将显示三列,分别为读取、写入和IO。
IO是最右边的列。请注意,IO中的sec列以秒为单位,而read和write列中基于时间的统计数据以毫秒为单位。
# vmstat -d | less
disk- ------------reads------------ ------------writes----------- -----IO------
total merged sectors ms total merged sectors ms cur sec
sda 13856 42 997627 232806 2862 1474 159957 525221 0 75
sr0 0 0 0 0 0 0 0 0 0 0
dm-0 13122 0 972701 231795 4313 0 155709 1075463 0 75
dm-1 88 0 4408 171 19 0 152 99 0 0
Reads
total:磁盘读取的总数。
merged:分组读取的总数。
sectors:已读入的扇区总数。
ms:从磁盘读取数据的总时间(毫秒)。
writes
total:磁盘写入的总数。
merged:分组写入的总数。
sectors:写入的扇区总数。
ms = 将数据写入磁盘所用的总时间(毫秒)。
IO
cur:当前磁盘读取或写入的次数。
sec:任何正在进行的读取或写入所花费的时间(秒)。
这里我们将看一看分区sda1。数字1表示这是设备sda上的第一个分区,sda是这台计算机的主硬盘驱动器。
# vmstat -p sda1
sda1 reads read sectors writes requested writes
574 13174 4 4096
返回的信息显示该分区的磁盘读写总数,以及磁盘读写操作中包含的扇区数。
Procs
r: 等待运行的进程数
b: 处在非中断睡眠状态的进程数
w: 被交换出去的可运行的进程数。
此数由 linux 计算得出,但 linux 并不耗尽交换空间
Memory
swpd: 虚拟内存使用情况,单位:KB
free: 空闲的内存,单位KB
buff: 被用来做为缓存的内存数,单位:KB
Swap
si: 从磁盘交换到内存的交换页数量,单位:KB/秒
so: 从内存交换到磁盘的交换页数量,单位:KB/秒
IO
bi: 发送到块设备的块数,单位:块/秒
bo: 从块设备接收到的块数,单位:块/秒
System
in: 每秒的中断数,包括时钟中断
cs: 每秒的环境(上下文)切换次数
CPU
按 CPU 的总使用百分比来显示
us: CPU 使用时间
sy: CPU 系统使用时间
id: 闲置时间
[1]DAVE MCKAY. How to Use the vmstat Command on Linux[EB/OL]. [2019年6月19日]. https://www.howtogeek.com/424334/how-to-use-the-vmstat-command-on-linux.
[2]所罗门 . VMSTAT(8)[EB/OL]. [2000-11-26]. http://cmpp.linuxforum.net.
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/zsx0728/article/details/119291375
内容来源于网络,如有侵权,请联系作者删除!