用途

查看系统资源整体使用情况,包括进程数量,CPU,内存,IO,swap等资源统计信息

用法

vmstat [options] [delay [ count]]

常用选项

-a

显示active/inactive内存

-f

显示forks的数量

-t

显示时间

-m

显示slab信息

-n

信息头部只输出一次,默认会周期性的输出

-s

表格形式显示事件计数器和内存的统计信息

-d

报告硬盘统计信息

-w

增加字段的宽度,显示更加易于查看

-p partition name

显示指定分区的统计信息

-S

内存显示单位(The -S followed by k or K or m or M switches outputs between 1000, 1024, 1000000, or 1048576 bytes)

-V

显示程序版本信息

实践

1 每个2秒报告一次系统情况

[root@vm ~]# vmstat 2
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 1022280 189004 13016 177984 8 21 46 107 313 419 2 1 96 1 0
1 0 1022280 188740 13024 178004 0 0 10 76 525 611 1 0 98 1 0
0 0 1022280 188856 13032 177996 0 0 10 12 367 402 0 1 98 1 0
0 0 1022280 188716 13032 178024 0 0 0 0 465 428 0 0 99 0 0
......

2 显示硬盘统计信息

[root@vm ~]# vmstat -d
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
ram3 0 0 0 0 0 0 0 0 0 0
ram4 0 0 0 0 0 0 0 0 0 0
ram5 0 0 0 0 0 0 0 0 0 0
ram6 0 0 0 0 0 0 0 0 0 0
ram7 0 0 0 0 0 0 0 0 0 0
ram8 0 0 0 0 0 0 0 0 0 0
ram9 0 0 0 0 0 0 0 0 0 0
ram10 0 0 0 0 0 0 0 0 0 0
ram11 0 0 0 0 0 0 0 0 0 0
ram12 0 0 0 0 0 0 0 0 0 0
ram13 0 0 0 0 0 0 0 0 0 0
ram14 0 0 0 0 0 0 0 0 0 0
ram15 0 0 0 0 0 0 0 0 0 0
loop0 0 0 0 0 0 0 0 0 0 0
loop1 0 0 0 0 0 0 0 0 0 0
loop2 0 0 0 0 0 0 0 0 0 0
loop3 0 0 0 0 0 0 0 0 0 0
loop4 0 0 0 0 0 0 0 0 0 0
loop5 0 0 0 0 0 0 0 0 0 0
loop6 0 0 0 0 0 0 0 0 0 0
loop7 0 0 0 0 0 0 0 0 0 0
sda 167694 114908 4595756 1453122 146213 1199662 10667146 3261091 0 583
disk- ------------reads------------ ------------writes----------- -----IO------
total merged sectors ms total merged sectors ms cur sec
dm-0 179304 0 3766554 1811878 1068455 0 8528160 18130295 0 542
dm-1 102612 0 820896 428945 267367 0 2138936 207822027 0 77

3 表格形式显示内存统计信息

[root@vm ~]# vmstat -s
3088360 total memory
2889484 used memory
2100284 active memory
629288 inactive memory
198876 free memory
10792 buffer memory
170184 swap cache
1675260 total swap
1028168 used swap
647092 free swap
124475 non-nice user cpu ticks
21 nice user cpu ticks
26541 system cpu ticks
4815453 idle cpu ticks
57706 IO-wait cpu ticks
5211 IRQ cpu ticks
1100 softirq cpu ticks
0 stolen cpu ticks
2300650 pages paged in
5367081 pages paged out
102312 pages swapped in
267367 pages swapped out
15726774 interrupts
21089251 CPU context switches
1521510912 boot time
76080 forks

输出字段说明

懒得翻译了,这里直接做个备份,日后查看使用

FIELD DESCRIPTION FOR VM MODE
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, included in idle.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown. FIELD DESCRIPTION FOR DISK MODE
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
s: seconds spent for I/O FIELD DESCRIPTION FOR DISK PARTITION MODE
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 FIELD DESCRIPTION FOR SLAB MODE
cache: Cache name
num: Number of currently active objects
total: Total number of available objects
size: Size of each object
pages: Number of pages with at least one active object
totpages: Total number of allocated pages
pslab: Number of pages per slab

参考资料

【1】man vmstat

【2】Linux vmstat命令实战详解

http://www.cnblogs.com/ggjucheng/archive/2012/01/05/2312625.html

【3】vmstat命令

http://man.linuxde.net/vmstat

【4】Linux inactive memory

https://unix.stackexchange.com/questions/305606/linux-inactive-memory

【5】What is active memory and inactive memory?

https://stackoverflow.com/questions/18529723/what-is-active-memory-and-inactive-memory

N天学习一个linux命令之vmstat的更多相关文章

  1. N天学习一个Linux命令之帮助命令:man

    前言 工作中每天都在使用常用的命令和非常用的命令,忘记了用法或者参数,都会bing一下,然后如此循环.一直没有真正的系统的深入的去了解命令的用法,我决定打破它.以前看到有人,每天学习一个linux命令 ...

  2. N天学习一个Linux命令之free

    用途 查看系统内存(物理/虚拟/缓存/共享)使用情况 用法 free [-b | -k | -m | -g | -h] [-o] [-s delay ] [-c count ] [-a] [-t] [ ...

  3. N天学习一个linux命令之ping

    用途 检测主机是否可到达,也就是说,目标主机是否可以联网,还可以用于检测网速.通过发送ICMP ECHO_REQUEST数据包检测. 用法 ping [options] destination 常用选 ...

  4. N天学习一个linux命令之kill

    用途 用于终止进程 用法 kill [-s signal|-p] [--] pid... kill -l [signal] 说明 1.默认发送信号15(请求终止进程,程序可以捕获,操作系统会杀死没有对 ...

  5. N天学习一个linux命令之du

    用途 统计文件或者目录占用硬盘空间大小 用法 du [OPTION] [FILE]du [OPTION] --files0-from=F 常用参数 -a, --all统计所有文件,不仅仅是目录 -b, ...

  6. N天学习一个linux命令之scp

    用途 通过ssh通道,不同主机之间复制文件 用法 scp [options] [user@host:]file1 [user2@host2:]file2 常用参数 -1使用 ssh 1协议 -2使用s ...

  7. 每天一个linux命令(36)--vmstat命令

    vmstat 是 Virtual Memory Statistics(虚拟内存统计)的缩写,可对操作系统的虚拟内存.进程.CPU活动进行监控.他是对系统的整体情况进行统计,不足之处是无法对某个进程进行 ...

  8. 每天学习一个Linux命令-目录

    在工作中总会零零散散使用到各种Linux命令,从今天开始详细的学习一下linux常用命令,坚持每天一个命令,学习的主要参考资料为: 1.竹子-博客(https://www.cnblogs.com/pe ...

  9. N天学习一个linux命令之umask

    前言 umask不是linux命令,而是shell内置的指令,俗称用户权限掩码,用于对用户创建的文件和目录设置默认权限.默认的权限掩码是0022,也就是说新创建的文件权限是0644,新创建的目录权限是 ...

随机推荐

  1. 0619-dedeCMS的安装、重装、目录说明、基本操作及注意事项

    一.安装步骤: 1.解压文件,将我们需要的uploads文件夹更名为dedeCMS 2.从站点下打开dedeCMS-install-index.php开始安装 3.安装完成后到php.ini中设置re ...

  2. [Swift通天遁地]四、网络和线程-(15)程序内购功能

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  3. 最全的C/C++入门到进阶的书籍推荐,你需要嘛?

    编程是操作性很强的一门知识,看书少不了,但只有学习和实践相结合才能起到很好的效果,一种学习方法是看视频->看书->研究书中例子->自己做些东西->交流->看书. 研究经典 ...

  4. AJAX json集合传入Controller后台

    HTML代码 <html> <head> <meta http-equiv="Content-Type" content="text/htm ...

  5. HDU 3007 最小圆覆盖 计算几何

    思路: 随机增量法 (好吧这数据范围并不用) //By SiriusRen #include <cmath> #include <cstdio> #include <al ...

  6. scrapy 框架持久化存储

    1.基于终端的持久化存储 保证爬虫文件的parse方法中有可迭代类型对象(通常为列表或字典)的返回,该返回值可以通过终端指令的形式写入指定格式的文件中进行持久化操作. # 执行输出指定格式进行存储:将 ...

  7. EF 新增数据时提示it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element

    it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionM ...

  8. Extension Methods(扩展方法)

    在 OOPL 中,有静态方法.实例方法和虚方法,如下:   public sealed class String {      public static bool  IsNullOrEmpty(st ...

  9. Windows Phone 8: NavigationInTransition实现页面切换效果

    NavigationInTransition这个是实现页面切换效果,而且没控件来拖,要自己手动写, 将App.xaml.cs中InitializePhoneApplication()函数里的RootF ...

  10. ajax请求参数的格式

    因为多写了一个contentType=“text/html”,请求的时候,参数总是转成了url&拼接的格式,导致请求不成功,调试了老半天 这个也是奇怪,为什么post只能接收json格式的数据 ...