GHOST系统之家 - Windows系统光盘下载网站!
当前位置:GHOST系统之家>系统问题 > Unix vmstat 命令详解宝典

Unix vmstat 命令详解宝典

来源:Ghost系统之家浏览:时间:2023-03-21 12:58:29

在一个多CPU系统中,vmstat统计所有个数的CPU的平均输出.为每个进程进行统计.没有参数时,vmstat显示每一行是自从系统启动以后的虚拟内存的活动情况.
vmstat 的语法我们可以通过linux的man 命令来查看。
将man 的结果导入到指定的文本
# man vmstat|col -b > /u01/tianlesoftware.txt

查看vmstat 用法
# man vmstat
VMSTAT(8) Linux Administrator’s Manual VMSTAT(8)
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]
DESCRIPTION
vmstat reports information about processes, memory, paging, block IO,
traps, and cpu activity.
The first report produced gives averages since the last reboot. Addi-
tional reports give information on a sampling period of length delay.
The process and memory reports are instantaneous in either case.
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 speci-
fied, 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.

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, shown as zero.

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
NOTES
vmstat does not require special permissions.

These reports are intended to help identify system bottlenecks. Linux
vmstat does not count itself as a running process.

All linux blocks are currently 1024 bytes. Old kernels may report
blocks as 512 bytes, 2048 bytes, or 4096 bytes.

Since procps 3.1.9, vmstat lets you choose units (k, K, m, M) default
is K (1024 bytes) in the default mode

vmstat uses slabinfo 1.1 FIXME
FILES
/proc/meminfo
/proc/stat
/proc/*/stat
SEE ALSO
iostat(1), sar(1), mpstat(1), ps(1), top(1), free(1)
BUGS
Does not tabulate the block io per device or count the number of sys-
tem calls.
AUTHORS
Written by Henry Ware <al172@yfn.ysu.edu>.
Fabian Frédérick <ffrederick@users.sourceforge.net> (diskstat, slab, partitions...)
Throatwobbler Ginkgo Labs 27 July 1994 VMSTAT(8)

示例:
# vmstat 2 10
procs -----------memory---------------------- -----swap--- -----io---- ---system--- ----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa
1 1 208 28960 38128 268204 0 0 278 40 1050 370 5 46 44 5
1 0 208 28896 38128 268204 0 0 128 0 1054 310 4 38 58 1
2 0 208 28896 38136 268196 0 0 257 55 1056 301 4 39 52 5
2 0 208 24896 38136 268196 0 0 257 1 1042 593 6 87 7 0
0 0 208 28672 38136 268196 0 0 257 25 1052 372 4 46 45 5
0 0 208 28824 38140 268192 0 0 129 111 1052 316 3 32 64 1
1 0 208 28768 38148 268184 0 0 257 109 1050 286 9 70 21 1
1 0 208 28512 38148 268184 0 0 257 1 1046 327 6 48 43 2
0 0 208 28832 38148 268184 0 0 257 1 1047 313 5 42 52 1
0 0 208 28832 38152 268180 0 0 257 109 1050 308 4 33 59 5

每2秒显示一次,共显示10次。

在Unix(Solaris)平台下:
-bash-3.00$ vmstat 2 10
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr s0 s1 -- -- in sy cs us sy id
0 0 0 5016344 4200040 126 512 35 0 0 0 0 0 1 0 0 731 1416 723 3 0 97
0 0 0 2065576 2375112 14 54 0 0 0 0 0 0 0 0 0 870 625 950 3 0 96
0 0 0 2065512 2375048 11 50 0 0 0 0 0 0 0 0 0 951 529 1066 3 0 97
0 0 0 2065512 2375048 11 53 0 0 0 0 0 0 0 0 0 852 548 934 3 0 97
0 0 0 2065512 2375048 4 40 0 0 0 0 0 0 0 0 0 836 483 907 3 0 97
0 0 0 2065512 2375048 14 46 0 0 0 0 0 0 0 0 0 873 632 958 3 0 97
0 0 0 2065512 2375048 0 0 0 0 0 0 0 0 0 0 0 812 417 863 3 0 97
0 0 0 2065512 2375048 4 40 0 0 0 0 0 0 0 0 0 810 481 874 3 0 97
0 0 0 2065384 2374920 0 0 0 0 0 0 0 0 1 0 0 801 406 862 3 0 96
0 0 0 2065384 2374920 14 46 0 0 0 0 0 0 0 0 0 817 545 898 3 0 97

一些标准说明:

CPU:
1) 如果(process r)是连续的大于在系统中的CPU的个数表示系统现在运行比较慢,有多数的进程等待CPU.
2) 如果r的输出数大于系统中可用CPU个数的4倍的话,则系统面临着CPU短缺的问题,或者是CPU的速率过低,系统中有多数的进程在等待CPU,造成系统中进程运行过慢.
3) 如果空闲时间(cpu id)持续为0并且系统时间(cpu sy)是用户时间的两倍(cpu us) 系统则面临着CPU资源的短缺.

简单的说就是:
r 和 b 不高于5,如果r 经常大于4,且id 经常少于40,则表示CPU 负荷很重。
us+sy 不超过80%,如果大于80,进程就会在运行队列中花费等待时间,响应时间和吞吐量就会下降。
wa 不超过25, 如果说wa >40表明磁盘io没有也许存在不合理的平衡,或者对磁盘操作比较频繁

一般情况下,导致CPU资源不足都是应用程序的问题.比如一些SQL语句不合理等等都会造成这样的现象.

内存:
si和so基本为零。 其中si表示当前每秒交换回内存(Swap in)的总量,单位为kbytes;so表示当前每秒交换出内存(Swap out)的总量,单位为kbytes。如果si,so 长期不等于0,表示系统使用swap 频繁,即内存不足。

一般情况下,如果内存的占用率比较高,但是,CPU的占用很低的时候,可以考虑是有很多的应用程序占用了内存没有释放.

要注意的是,Linux 内存在使用后不会释放,所以一般会看到内存使用率很高,要判断linux 内存是否正常,需要通过对swap 交换区的交换频率来看。

标签:

推荐系统

  • 微软Win11原版22H2下载_Win11GHOST 免 激活密钥 22H2正式版64位免费下载

    微软Win11原版22H2下载_Win11GHOST 免 激活密钥 22H2正式版64位免费下载

    语言:中文版系统大小:5.13GB系统类型:Win11

    微软Win11原版22H2下载_Win11GHOST 免 激活密钥 22H2正式版64位免费下载系统在家用办公上跑分表现都是非常优秀,完美的兼容各种硬件和软件,运行环境安全可靠稳定。Win11 64位 Office办公版(免费)优化  1、保留 Edge浏览器。  2、隐藏“操作中心”托盘图标。  3、保留常用组件(微软商店,计算器,图片查看器等)。  5、关闭天气资讯。 

  • Win11 21H2 官方正式版下载_Win11 21H2最新系统免激活下载

    Win11 21H2 官方正式版下载_Win11 21H2最新系统免激活下载

    语言:中文版系统大小:4.75GB系统类型:Win11

    Ghost Win11 21H2是微软在系统方面技术积累雄厚深耕多年,Ghost Win11 21H2系统在家用办公上跑分表现都是非常优秀,完美的兼容各种硬件和软件,运行环境安全可靠稳定。Ghost Win11 21H2是微软最新发布的KB5019961补丁升级而来的最新版的21H2系统,以Windows 11 21H2 22000 1219 专业版为基础进行优化,保持原汁原味,系统流畅稳定,保留常用组件

  • windows11中文版镜像 微软win11正式版简体中文GHOST ISO镜像64位系统下载

    windows11中文版镜像 微软win11正式版简体中文GHOST ISO镜像64位系统下载

    语言:中文版系统大小:5.31GB系统类型:Win11

    windows11中文版镜像 微软win11正式版简体中文GHOST ISO镜像64位系统下载,微软win11发布快大半年了,其中做了很多次补丁和修复一些BUG,比之前的版本有一些功能上的调整,目前已经升级到最新版本的镜像系统,并且优化了自动激活,永久使用。windows11中文版镜像国内镜像下载地址微软windows11正式版镜像 介绍:1、对函数算法进行了一定程度的简化和优化

  • 微软windows11正式版GHOST ISO镜像 win11下载 国内最新版渠道下载

    微软windows11正式版GHOST ISO镜像 win11下载 国内最新版渠道下载

    语言:中文版系统大小:5.31GB系统类型:Win11

    微软windows11正式版GHOST ISO镜像 win11下载 国内最新版渠道下载,微软2022年正式推出了win11系统,很多人迫不及待的要体验,本站提供了最新版的微软Windows11正式版系统下载,微软windows11正式版镜像 是一款功能超级强大的装机系统,是微软方面全新推出的装机系统,这款系统可以通过pe直接的完成安装,对此系统感兴趣,想要使用的用户们就快来下载

  • 微软windows11系统下载 微软原版 Ghost win11 X64 正式版ISO镜像文件

    微软windows11系统下载 微软原版 Ghost win11 X64 正式版ISO镜像文件

    语言:中文版系统大小:0MB系统类型:Win11

    微软Ghost win11 正式版镜像文件是一款由微软方面推出的优秀全新装机系统,这款系统的新功能非常多,用户们能够在这里体验到最富有人性化的设计等,且全新的柔软界面,看起来非常的舒服~微软Ghost win11 正式版镜像文件介绍:1、与各种硬件设备兼容。 更好地完成用户安装并有效地使用。2、稳定使用蓝屏,系统不再兼容,更能享受无缝的系统服务。3、为

  • 雨林木风Windows11专业版 Ghost Win11官方正式版 (22H2) 系统下载

    雨林木风Windows11专业版 Ghost Win11官方正式版 (22H2) 系统下载

    语言:中文版系统大小:4.75GB系统类型:

    雨林木风Windows11专业版 Ghost Win11官方正式版 (22H2) 系统下载在系统方面技术积累雄厚深耕多年,打造了国内重装系统行业的雨林木风品牌,其系统口碑得到许多人认可,积累了广大的用户群体,雨林木风是一款稳定流畅的系统,一直以来都以用户为中心,是由雨林木风团队推出的Windows11国内镜像版,基于国内用户的习惯,做了系统性能的优化,采用了新的系统

  • 雨林木风win7旗舰版系统下载 win7 32位旗舰版 GHOST 免激活镜像ISO

    雨林木风win7旗舰版系统下载 win7 32位旗舰版 GHOST 免激活镜像ISO

    语言:中文版系统大小:5.91GB系统类型:Win7

    雨林木风win7旗舰版系统下载 win7 32位旗舰版 GHOST 免激活镜像ISO在系统方面技术积累雄厚深耕多年,加固了系统安全策略,雨林木风win7旗舰版系统在家用办公上跑分表现都是非常优秀,完美的兼容各种硬件和软件,运行环境安全可靠稳定。win7 32位旗舰装机版 v2019 05能够帮助用户们进行系统的一键安装、快速装机等,系统中的内容全面,能够为广大用户

  • 番茄花园Ghost Win7 x64 SP1稳定装机版2022年7月(64位) 高速下载

    番茄花园Ghost Win7 x64 SP1稳定装机版2022年7月(64位) 高速下载

    语言:中文版系统大小:3.91GB系统类型:Win7

    欢迎使用 番茄花园 Ghost Win7 x64 SP1 2022.07 极速装机版 专业装机版具有更安全、更稳定、更人性化等特点。集成最常用的装机软件,集成最全面的硬件驱动,精心挑选的系统维护工具,加上独有人性化的设计。是电脑城、个人、公司快速装机之首选!拥有此系统