vmstat测试

vmstat测试:
场景:tar -zvcf 2_104.tar.gz ./* 打包压缩3GB+文件


[root@localhost opt]# vmstat 1 1000
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 378768 166976 462460 4875564 0 0 0 7 0 1 0 0 100 0 0
1 0 378768 166844 462460 4875968 0 0 28480 0 1581 3262 24 1 74 0 0
0 2 378768 167092 462464 4876812 0 0 33920 28 1573 3324 25 1 74 1 0
1 0 378768 166960 462460 4877716 0 0 31872 0 1663 3407 23 1 74 2 0
1 0 378768 167092 462460 4878564 0 0 33920 0 1704 3391 25 2 74 0 0
1 0 378768 167092 462460 4879332 0 0 33792 0 1623 3374 25 1 74 0 0
1 0 378768 173664 462460 4873316 0 0 32640 0 1568 3205 25 1 74 0 0
1 1 378768 188420 462456 4859208 0 0 31744 8 1598 3212 24 1 73 2 0
1 0 378768 198712 462456 4850252 0 0 30080 4 1590 3095 24 1 73 2 0
1 0 378768 201952 462456 4848028 0 0 32896 0 1740 3342 25 1 74 0 0
1 0 378768 204804 462456 4846508 0 0 30848 8 1547 3031 24 1 74 1 0
2 0 378768 207036 462452 4845176 0 0 30976 0 1579 3126 24 1 74 1 0
0 2 378768 220552 462452 4832756 0 0 32256 20 1554 3166 24 1 74 1 0
1 0 378768 225024 462452 4829352 0 0 31232 0 1602 3255 24 1 74 1 0
1 0 378768 311080 462452 4744532 0 0 31372 0 1599 3143 23 2 72 3 0
1 0 378768 351752 462452 4704668 0 0 30592 52 1585 3117 24 1 74 1 0
1 1 378768 359384 462452 4696436 0 0 24404 36 1608 2774 18 4 66 12 0
1 1 378768 366436 462456 4690284 0 0 26512 0 1707 2985 20 3 58 19 0
2 0 378768 366652 462448 4690176 0 0 25688 0 1694 2892 20 3 57 20 0
1 1 378768 366540 462448 4689948 0 0 27168 0 2300 3351 21 5 54 21 0
1 1 378768 427004 462444 4628972 0 0 26444 0 1792 3111 20 2 58 20 0
1 0 378768 540372 462444 4508336 0 0 24840 64 1569 2769 20 3 67 11 0
0 1 378768 575712 462448 4470492 0 0 32644 73728 1617 3224 25 2 73 1 0
1 0 378768 575092 462448 4471336 0 0 20224 57344 1313 2340 15 1 57 27 0
1 0 378768 539132 462448 4511680 0 0 22400 0 1310 2329 17 1 75 7 0
1 0 378768 471304 462448 4579872 0 0 34048 0 1579 3359 25 2 73 0 0
1 0 378768 409188 462456 4642512 0 0 31232 24 1457 3025 23 2 72 3 0
0 2 378768 351032 462464 4696388 0 0 27156 94788 1435 2812 22 2 69 9 0
0 2 378768 317056 462464 4730548 0 0 17152 98304 1183 1973 14 1 51 35 0
1 1 378768 288304 462468 4759592 0 0 14288 89600 1183 1839 12 1 50 37 0
1 1 378768 250128 462476 4797552 0 0 19204 94208 1157 2045 15 1 53 31 0
0 3 378768 221376 462480 4826580 0 0 15108 98304 1098 9324 12 1 49 37 0
0 3 378768 186160 462480 4860756 0 0 17280 81972 1179 18306 14 2 37 47 0
2 2 378768 149000 462484 4897556 0 0 18436 81408 1450 2841 15 1 47 37 0
1 2 378768 147380 462488 4897168 0 0 17028 98304 1200 2258 13 1 48 38 0
0 3 378768 168948 462488 4876964 0 0 19228 49160 1560 2618 16 4 47 33 0
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 2 378768 169444 462492 4876724 0 0 22916 65536 1318 2604 18 1 60 21 0
1 2 378768 165260 462496 4882556 0 0 17664 65612 2069 5231 14 1 55 30 0
1 2 378768 132028 462496 4917976 0 0 17728 24092 1141 2326 14 1 49 37 0
1 0 378768 168864 462496 4882572 0 0 30208 4 1671 3134 23 2 72 3 0
1 0 378768 168740 462496 4883856 0 0 17856 0 1480 2923 25 1 74 0 0
1 0 378768 169004 462496 4883264 0 0 0 0 1393 2698 25 1 74 0 0
1 0 378768 168632 462496 4884564 0 0 25984 24 1511 3040 23 1 72 4 0
1 0 378768 168640 462492 4884548 0 0 33152 8 1701 3438 25 2 74 0 0
1 0 378768 235212 462492 4818364 0 0 12400 0 1428 2908 25 2 74 0 0
1 0 378768 181164 462492 4872292 0 0 20352 0 1451 3091 25 1 74 0 0
2 0 378768 131952 462488 4920060 0 0 33408 0 1538 3233 25 1 74 0 0
1 0 378768 165308 462480 4888248 0 0 30720 28 1569 3125 23 1 73 3 0
2 0 378768 268104 462480 4785852 0 0 33920 0 1681 3440 25 2 74 0 0
1 0 378768 267616 462480 4786640 0 0 31400 0 1673 3207 24 2 72 3 0
1 0 378768 429552 462480 4625392 0 0 20124 0 1549 3028 25 2 74 0 0
1 0 378768 458320 462480 4597488 0 0 33408 0 1658 3340 25 1 74 0 0
1 0 378768 461544 462480 4595012 0 0 15184 12 1392 2789 23 1 73 3 0
1 0 378768 463528 462480 4593712 0 0 22460 0 1607 3264 25 1 74 0 0
1 0 378768 468968 462480 4588248 0 0 32496 0 1859 3342 25 1 73 0 0
1 0 378768 476548 462480 4581508 0 0 24768 0 1572 3246 25 2 74 0 0
1 0 378768 485476 462480 4572956 0 0 11120 0 1477 2937 25 1 74 0 0
2 0 378768 492668 462476 4566572 0 0 31232 12 1685 3192 23 1 72 3 0
1 0 378768 494900 462184 4565308 0 0 28448 0 1705 3323 25 1 74 0 0
1 0 378768 495256 462172 4566180 0 0 33408 0 1713 3385 25 2 73 0 0
1 0 378768 495272 462172 4566488 0 0 11368 0 1426 2907 25 1 74 0 0
0 1 378768 496884 462176 4564008 0 0 32260 33760 1605 3245 24 1 74 1 0
1 2 378768 493288 462180 4569680 0 0 8560 97340 1497 2408 20 2 61 16 0
1 0 378768 434884 462180 4627904 0 0 28736 0 1483 3136 22 1 73 5 0
1 0 378768 375472 462180 4686196 0 0 24480 0 1520 3149 25 1 74 0 0
1 0 378768 341388 462180 4719860 0 0 416 0 1273 2754 25 1 74 0 0
0 2 378768 304312 462184 4752728 0 0 12900 161968 1152 1998 15 2 59 25 0
2 2 378768 272692 462188 4783600 0 0 11780 121344 1227 5123 15 2 51 33 0
2 2 378768 254464 462196 4801364 0 0 3032 143908 1158 36637 11 3 44 42 0
0 3 378768 214048 462196 4841644 0 0 20096 81920 1287 2523 15 2 51 32 0
1 2 378768 172632 462200 4882564 0 0 20484 81920 1158 2425 15 1 47 36 0
0 3 378768 133944 462200 4920944 0 0 19200 81920 1179 2401 14 1 50 35 0
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 2 378904 146840 462192 4908124 0 136 19076 83080 1169 2364 14 1 44 41 0
1 2 378904 167672 462192 4887740 0 0 17796 98304 1304 2493 14 1 49 37 0
0 1 378904 163084 462192 4894828 0 0 10608 56736 995 1761 8 1 67 24 0
1 0 378904 140268 462192 4919900 0 0 27136 0 1420 2795 20 1 74 4 0
1 0 379032 167548 462192 4894344 0 128 33280 128 1614 3248 25 1 74 0 0
2 0 379032 167672 462192 4895004 0 0 33792 0 1670 3367 25 1 74 0 0
1 0 379032 168176 462192 4895628 0 0 33920 0 1666 3398 25 1 74 0 0
1 1 379032 168044 462200 4893284 0 0 29064 88664 1588 3035 22 2 69 8 0
0 2 379032 169160 462200 4892636 0 0 19840 65536 1250 2121 15 1 51 34 0
0 1 379032 169408 462204 4895864 0 0 18052 30300 1257 2050 14 1 70 16 0
2 0 379032 168292 462204 4898564 0 0 33152 0 1606 3240 25 1 74 1 0
1 0 379032 168788 462204 4898692 0 0 33920 0 1699 3488 25 1 74 0 0
1 0 379032 168896 462204 4899236 0 0 30592 32 1557 3092 23 2 71 5 0
1 0 379032 168912 462204 4900244 0 0 33920 0 1664 3378 25 2 74 0 0
1 0 379032 189620 462204 4880236 0 0 33920 0 1621 3324 25 1 74 0 0
1 0 379032 196564 462204 4873740 0 0 34048 0 1656 3392 25 2 74 0 0
1 0 379032 200160 462204 4870572 0 0 33792 0 1698 3413 25 1 74 0 0
1 0 379032 205120 462200 4866292 0 0 29964 12 1598 3108 22 1 70 6 0
1 0 379032 214296 462200 4857688 0 0 33920 0 1779 3925 25 1 74 0 0
1 0 379032 214172 462200 4859060 0 0 34048 0 1654 3377 25 2 74 0 0
1 0 379032 213800 462200 4860004 0 0 32896 0 1594 3209 25 2 74 0 0
1 0 379032 213924 462200 4860744 0 0 33640 0 1925 3779 25 1 74 0 0
1 0 379032 212064 462204 4862716 0 0 17172 12 1482 2905 23 2 72 3 0
1 0 379032 212396 462204 4862404 0 0 1308 0 1573 2962 24 2 66 9 0
2 0 379032 212652 462204 4862920 0 0 18368 0 1455 2850 24 1 74 1 0
1 0 379032 212404 462204 4863496 0 0 26880 0 1591 3235 25 1 74 0 0
1 0 379032 212528 462200 4862988 0 0 33408 0 1665 3356 25 1 74 0 0
1 0 379032 212848 462200 4863900 0 0 10304 44 1515 2924 24 2 71 3 0
1 0 379032 213592 462200 4864236 0 0 23616 0 1548 3052 25 2 74 0 0
2 0 379032 212980 462200 4864940 0 0 13104 0 1490 2938 25 1 74 0 0
1 0 379032 213352 462200 4864940 0 0 22720 0 1508 3094 25 1 74 0 0
1 0 379032 213360 462200 4865344 0 0 20064 0 1600 3216 25 1 74 0 0
0 1 379032 215328 462200 4863564 0 0 31104 96 1613 3176 23 2 72 3 0
1 0 379032 215492 462204 4859740 0 0 20484 135088 1351 2306 15 2 59 25 0
1 0 379032 218344 462204 4860252 0 0 11152 0 1418 2527 21 1 75 4 0
1 0 379032 219584 462204 4859096 0 0 18384 0 1558 3106 25 1 74 0 0
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 379032 222436 462204 4857340 0 0 20496 0 1600 3238 25 1 74 0 0
1 1 379032 227148 462204 4849072 0 0 27816 96840 1701 2926 21 3 61 15 0
1 1 379032 192924 462208 4884548 0 0 17668 82460 1074 1902 13 1 52 34 0
0 1 379032 158576 462212 4918364 0 0 17028 66032 1104 1903 13 1 50 36 0
1 1 379032 129312 462216 4946712 0 0 4452 172064 1336 2163 18 2 55 26 0
2 2 379408 147416 462212 4928384 0 376 17920 82296 1245 2173 14 1 52 33 0
1 2 379408 144308 462216 4930988 0 0 21508 72756 1308 2414 16 2 46 36 0
0 3 379544 169736 462216 4906432 0 136 20992 65672 1256 2497 16 1 43 41 0
0 3 379544 169488 462224 4907256 0 0 7496 132088 1295 2723 16 1 32 50 0
1 2 379544 127700 462224 4947952 0 0 20416 80920 1195 2461 15 1 48 36 0
1 1 379792 139108 462228 4938156 0 248 15620 67320 1267 2473 15 1 51 32 0
0 0 379928 162024 462228 4917816 0 136 11712 180 1667 2765 21 2 71 6 0
0 0 379928 162156 462228 4918032 0 0 0 0 248 399 0 0 99 0 0
0 0 379928 162156 462228 4918032 0 0 0 0 268 445 1 0 99 0 0
0 0 379928 162156 462228 4918032 0 0 0 0 212 364 0 0 99 0 0
0 0 379928 160172 462228 4918032 0 0 0 60472 423 585 1 1 99 0 0
1 0 379928 162016 462228 4918032 0 0 0 0 407 421 1 1 99 0 0
0 0 379928 162280 462236 4918024 0 0 0 40 289 480 1 0 98 1 0
1 0 379928 162280 462236 4918032 0 0 0 0 214 365 0 0 100 0 0
0 0 379928 162404 462236 4918032 0 0 0 0 273 470 1 0 99 0 0
0 0 379928 162528 462236 4918032 0 0 0 0 271 443 1 0 99 0 0


打包压缩开始时bi(磁盘读取)很高, 当读取完成一个文件,开始写入(bo升高),bo增高时,cpu的wa(等待)增高


r 表示进程在运行队列中排队   (就是说多少个进程真的分配到CPU),我测试的服务器目前CPU比较空闲,没什么程序在跑,当这个值超过了CPU数目,就会出现CPU瓶颈了。这个也和top的负载有关系,一般负载超过了3就比较高,超过了5就高,超过了10就不正常了,服务器的状态很危险。top的负载类似每秒的运行队列。如果运行队列过大,表示你的CPU很繁忙,一般会造成CPU使用率很高。

b 表示阻塞的进程, 即 进程阻塞等待IO请求完成的数目。

swpd 虚拟内存已使用的大小,如果大于0,表示你的机器物理内存不足了,如果不是程序内存泄露的原因,那么你该升级内存了或者把耗内存的任务迁移到其他机器。

free 空闲的物理内存的大小,我的机器内存总共8G,剩余3415M。

buff Linux/Unix系统是用来存储,目录里面有什么内容,权限等的缓存,我本机大概占用300多M

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

si 每秒从磁盘读入虚拟内存的大小,如果这个值大于0,表示物理内存不够用或者内存泄露了,要查找耗内存进程解决掉。我的机器内存充裕,一切正常。

so 每秒虚拟内存写入磁盘的大小,如果这个值大于0,同上。

bi 块设备每秒接收的块数量,这里的块设备是指系统上所有的磁盘和其他块设备,默认块大小是1024byte,我本机上没什么IO操作,所以一直是0,但是我曾在处理拷贝大量数据(2-3T)的机器上看过可以达到140000/s,磁盘写入速度差不多140M每秒

bo 块设备每秒发送的块数量,例如我们读取文件,bo就要大于0。bi和bo一般都要接近0,不然就是IO过于频繁,需要调整。

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

cs 每秒上下文切换次数,例如我们调用系统函数,就要进行上下文切换,线程的切换,也要进程上下文切换,这个值要越小越好,太大了,要考虑调低线程或者进程的数目,例如在apache和nginx这种web服务器中,我们一般做性能测试时会进行几千并发甚至几万并发的测试,选择web服务器的进程可以由进程或者线程的峰值一直下调,压测,直到cs到一个比较小的值,这个进程和线程数就是比较合适的值了。系统调用也是,每次调用系统函数,我们的代码就会进入内核空间,导致上下文切换,这个是很耗资源,也要尽量避免频繁调用系统函数。上下文切换次数过多表示你的CPU大部分浪费在上下文切换,导致CPU干正经事的时间少了,CPU没有充分利用,是不可取的。

us 用户CPU时间,我曾经在一个做加密解密很频繁的服务器上,可以看到us接近100,r运行队列达到80(机器在做压力测试,性能表现不佳)。

sy 系统CPU时间,如果太高,表示系统调用时间长,例如是IO操作频繁。

id 空闲 CPU时间,一般来说,id + us + sy = 100,一般我认为id是空闲CPU使用率,us是用户CPU使用率,sy是系统CPU使用率。

wt 等待IO CPU时间。

FIELD DESCRIPTION FOR VM MODE
   Procs
       r: The number of runnable processes (running or 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.
原文地址:https://www.cnblogs.com/yum777/p/8565428.html