Linux系统监控:vmstat

简介:

vmstat命令可以查看当前运行JAVA程序的Linux系统的CPU使用率、CPU调度程序运行队列的长度以及内存使用率(包括内存使用情况、是否存在内存交换等)。

使用方法:

vmstat 1 5:1秒采集一次,共采集5次

vmstat 1:一秒采集一次,直到结束程序

vmstat -s:显示内存的详细信息

vmstat -d 1 5:显示磁盘的详细信息

输出示例:

[grucee@localhost notes]$ vmstat 1 5

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----

 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa

 1  0      0 6279892  32708 702664    0    0   248    23  210  723  4  1 90  5

 0  0      0 6275908  32716 706992    0    0     0   100  653 3449  2  1 95  2

 0  0      0 6275620  32724 707080    0    0     0   660  631 3250  2  1 95  2

 0  0      0 6275752  32724 707032    0    0     0     0  526 2670  2  1 98  0

 0  0      0 6275876  32724 706796    0    0     0     0  385 2402  2  1 98  0

VM模式输出详解(默认模式)

 Procs

       r: The number of runnable processes (running or waiting for run time).

          运行的进程数(正在运行或等待运行)

       b: The number of processes in uninterruptible sleep.

          处在非中断sleep状态的进程数。

 Memory

       swpd: the amount of virtual memory used.

             已经使用的虚拟内存(交换分区)总量,大于零说明物理内存不足。

       free: the amount of idle memory.

             空闲内存总量

       buff: the amount of memory used as buffers.

             用于缓存的内存总量(如linux的/proc目录下面的内容就是在缓存中的)

       cache: the amount of memory used as cache.

             cache直接用来记忆我们打开的文件,给文件做缓冲,(Linux/Unix把空闲的物理内存的一部分拿来做文件和目录的缓存,是为了提高 程序执行的性能,当程序使用内存时,buffer/cached会很快地被使用。)

       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.

           每秒CPU的中断次数,包括时钟中断

       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)

           用户态CPU时间

       sy: Time spent running kernel code.  (system time)

           系统态CPU时间

       id: Time spent idle.  Prior to Linux 2.5.41, this includes IO-wait time.

           空闲CPU时间

       wa: Time spent waiting for IO.  Prior to Linux 2.5.41, included in idle.

           等待IO CPU时间

       st: Time stolen from a virtual machine.  Prior to Linux 2.6.11, unknown.

           从虚拟机偷来的CPU时间

磁盘模式详解(指定-d选项)

   Reads

       total: Total reads completed successfully

       成功完成的读操作数目。

       merged: grouped reads (resulting in one I/O)

       合并的读(在一次I/O中)

       sectors: Sectors read successfully

       成功读的扇区数

       ms: milliseconds spent reading

       花费在读操作上的毫秒数。

   Writes

       total: Total writes completed successfully

       成功完成的写操作数目。

       merged: grouped writes (resulting in one I/O)

       合并的写(在一次I/O中)

       sectors: Sectors written successfully

       成功写的扇区数

       ms: milliseconds spent writing

       花费在写操作上的毫秒数。

   IO

       cur: I/O in progress

       正在处理I/O的进程数

       s: seconds spent for I/O

       花费在I/O上的秒数

SLAB模式详解(指定-m选项,需要root权限)

       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

             至少有一个活动对象的页数。

相关推荐