Linux性能测试 vmstat命令

vmstat命令是最常见的Linux/Unix监控工具,可以展现给定时间间隔的服务器的状态值,包括服务器的CPU使用率,内存使用,虚拟内存交换情况,IO读写情况。这个命令是我查看Linux/Unix最喜爱的命令,一个是Linux/Unix都支持,二是相比top,我可以看到整个机器的CPU,内存,IO的使用情况,而不是单单看到各个进程的CPU使用率和内存使用率(使用场景不一样)。

NAME
       vmstat - Report virtual memory statistics
SYNOPSIS
       vmstat [-a] [-n] [delay [ count]]
       vmstat [-f] [-s] [-m]
       vmstat [-S unit]
       vmstat [-d]
       vmstat [-p disk partition]
       vmstat [-V]
   Options
       The -a switch displays active/inactive memory, given a 2.5.41 kernel or better.
       The -f switch displays the number of forks since boot.  This includes the fork, vfork, and clone system calls, and is equivalent to  the  total  number  of
       tasks created. Each process is represented by one or more tasks, depending on thread usage.  This display does not repeat.
       The -m displays slabinfo.
       The -n switch causes the header to be displayed only once rather than periodically.
       The -s switch displays a table of various event counters and memory statistics. This display does not repeat.
       delay is the delay between updates in seconds.  If no delay is specified, only one report is printed with the average values since boot.
       count is the number of updates.  If no count is specified and delay is defined, count defaults to infinity.
       The -d reports disk statistics (2.5.70 or above required)
       The -p followed by some partition name for detailed statistics (2.5.70 or above required)
       The -S followed by k or K or m or M switches outputs between 1000, 1024, 1000000, or 1048576 bytes
       The -V switch results in displaying version information.

 

一般vmstat工具的使用是通过两个数字参数来完成的,第一个参数是采样的时间间隔数,单位是秒,第二个参数是采样的次数,如:

[root@C44 ~]#  vmstat 2 3
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 0  0      0 142020  66240 225220    0    0     1    10  222    22  0  0 100  0
 0  0      0 142020  66240 225220    0    0     0     0 1162    45  0  0 100  0
 0  0      0 141892  66240 225220    0    0     0     0 1096    62  0  0 100  0
[root@C44 ~]#  

2表示每个两秒采集一次服务器状态,3表示采集三次。

 

实际上,在应用过程中,我们会在一段时间内一直监控,不想监控直接结束ctrl+c就行了,例如:

[root@C44 ~]#  vmstat 2 
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 0  0      0 141972  66224 225236    0    0     1    10  221    22  0  0 100  0
 0  0      0 141972  66224 225236    0    0     0    74 1064    34  0  0 100  0
 0  0      0 141972  66224 225236    0    0     0     0 1064    32  0  0 100  0
 0  0      0 141972  66224 225236    0    0     0     0 1054    34  0  0 100  0
 0  0      0 141772  66224 225236    0    0     0     0 1058    62  0  0 100  0


 vmstat命令输出分成六个部分:
  (1)进程procs:
  r:在运行队列中等待的进程数 。
  b:在等待io的进程数 。
  (2)内存memoy:
  swpd:现时可用的交换内存(单位KB)。
  free:空闲的内存(单位KB)。
  buff: 缓冲去中的内存数(单位:KB)。
  cache:被用来做为高速缓存的内存数(单位:KB)。
  (3) swap交换页面
  si: 从磁盘交换到内存的交换页数量,单位:KB/秒。
  so: 从内存交换到磁盘的交换页数量,单位:KB/秒。
  (4) io块设备:
  bi: 发送到块设备的块数,单位:块/秒。
  bo: 从块设备接收到的块数,单位:块/秒。
  (5)system系统:
  in: 每秒的中断数,包括时钟中断。
  cs: 每秒的环境(上下文)切换次数。
  (6)cpu中央处理器:
  cs:用户进程使用的时间 。以百分比表示。
  sy:系统进程使用的时间。 以百分比表示。
  id:中央处理器的空闲时间 。以百分比表示。
     wa:等待IO CPU时间。


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值