linux基本监控-vmstat

来源:互联网 发布:linux 注释多行 编辑:程序博客网 时间:2024/05/01 10:51
1.vmstat
vmstat(Virtual Meomory Statistics(虚拟内存统计)的缩写,很多linux、unix会默认安装。是内核线程、虚拟内存、磁盘、陷阱和 CPU 活动的统计信息,不足是无法对某个进程深入分析。



虚拟内存:
系统中运行的进程都需要使用内存,当内存不足时,内核会释放某些进程所占用但未使用的部分或所有物理内存,将其移到磁盘上,并将释放的内存提供给需要使用的进程。



语法:vmstat [ -f ] [ -i ] [ -s ] [ -I ] [ -t ] [ -v ] [ PhysicalVolume ... ] [ Interval [ Count ] ]


[root@db-331 ~]# vmstat help
usage: vmstat [-V] [-n] [delay [count]]
              -V prints version.   版本信息。
              -n causes the headers not to be reprinted regularly. 输出的头部信息仅显示一次。
              -a print inactive/active page stats. 打印待用/活跃 的页状态,默认不打印。
              -d prints disk statistics 打印磁盘统计信息。
              -D prints disk table       打印磁盘总信息,包括读写分区等。
              -p prints disk partition statistics 打印磁盘分区统计。
              -s prints vm table 
              -m prints slabinfo
              -S unit size    单位大小。
 delay is the delay between updates in seconds.delay表示两次输出之间间隔时间。
 unit size k:1000 K:1024 m:1000000 M:1048576 (default is K) 指定单位,参数有k,K,m,M分别代表1000、1024、1000000、1048576(byte),默认K(1024 bytes)
              count is the number of updates. count表示统计的次数,默认1.
例如:
vmstat 3 5
表示每3秒更新一次输出信息,统计5次。
[root@db-331 ~]# 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    624 109784 338108 18696476    0    0     0    15    0    0  0  0 99  0  0
 0  0    624 108796 338108 18697148    0    0     5   939 6693 6865  0  0 99  0  0
 0  0    624 108764 338124 18697624    0    0     5  1036 6172 6325  0  0 99  0  0
 0  0    624 109628 338124 18698132    0    0     0   733 5054 4822  0  0 99  0  0
 0  0    624 109832 338124 18698420    0    0    11   725 5031 4875  0  0 100  0  0


Procs(进程):
r: 运行队列中进程数量。当这个值长期超过了CPU数目,表示CPU有瓶颈
b: 等待IO的进程数量

Memory(默认单位K):
swpd: 正使用虚拟内存大小
free: 可用内存大小
buff: 用作缓冲的内存大小
cache: 用作缓存的内存大小

Swap:
si: 每秒从交换区写到内存的大小(由磁盘调入内存)
so: 每秒写入交换区的内存大小(由内存调入磁盘)   


IO:
bi: 每秒读取的块数
bo: 每秒写入的块数


system:
in: 每秒中断数,包括时钟中断。
cs: 每秒上下文切换数。


CPU(以百分比表示):
us: 用户进程消耗的CPU时间百分比
sy: 系统进程消耗的CPU时间百分比
id: 空闲时间(包括IO等待时间)
wa: O等待消耗的CPU时间百分比