了解 vmstat 内存利用率的输出

问题描述

我有一个solaris盒子,我想知道它是内存不足还是稳定。

下面是vmstat的输出

 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr vc vc vc vc   in   sy   cs us sy id
 1 0 0 11426696 4603520 613 1477 449 6 6 0 0 78 22 28 29 8970 37714 22961 43 6 51
 4 0 0 4975280    0 1747 3487 805 0 0 0  0 233 41 33 44 9558 53713 15845 74 8 18
 4 0 0 4936944    0 933 1837 0  0  0  0  0 56 28 12 39 9317 46898 14648 82 7 11
 5 0 0 4943080    0 1056 2806 805 0 0 0  0 103 21 18 18 9286 46900 14866 78 8 14
 5 0 0 4942264    0 1088 2173 804 6 6 0  0 109 8 40 31 9927 56484 16495 84 8 8
 3 0 0 4942520    0 308 1018 1756 3 3 0  0 166 87 29 44 10638 64146 21413 83 9 8
 0 0 0 4942512    0 156 326 1740 0 0  0  0 370 12 33 52 11554 40375 21897 75 9 16
 2 0 0 4947384    0 294 560 845 0  0  0  0 121 18 23 20 9445 52382 17016 77 6 17

我可以看到空闲列显示 0 但 sr 列也显示 0

并且 top 命令的输出没有显示有多少可用内存。掉期显示 0.0%

load averages:  11.4,9.12,9.24;                   
9021 processes: 9018 sleeping,1 running,2 on cpu
cpu states:  0.0% idle,71.4% user,28.6% kernel,0.0% iowait,0.0% swap
Memory: 24G phys mem,16G total swap,13G free swap

我的内存用完了吗? 请建议如何解释这些数据。我需要增加物理内存吗?

欣赏一些见解。

解决方法

Solaris 11.4 vmstat man page 中,有一件重要的事情需要注意:

如果没有选项,vmstat 显示自系统启动以来虚拟内存活动的单行摘要。

这也适用于 Solaris vmstat 的第一行输出:它是自系统启动以来所有活动的摘要。

在 Solaris man vmstat 页面的 EXAMPLES 部分中可以找到对输出字段的很好的描述:

示例

示例 1 使用 vmstat

以下命令显示系统正在执行的操作的摘要 每五秒一次。

示例% vmstat 5

kthr   memory          page             disk      faults        cpu
r b w swap  free re mf pi p fr de sr s0 s1 s2 s3  in  sy  cs us sy id
0 0 0 11456 4120 1  41 19 1  3  0  2  0  4  0  0  48 112 130  4 14 82
0 0 1 10132 4280 0   4 44 0  0  0  0  0 23  0  0 211 230 144  3 35 62
0 0 1 10132 4616 0   0 20 0  0  0  0  0 19  0  0 150 172 146  3 33 64
0 0 1 10132 5292 0   0  9 0  0  0  0  0 21  0  0 165 105 130  1 21 78
1 1 1 10132 5496 0   0  5 0  0  0  0  0 23  0  0 183  92 134  1 20 79
1 0 1 10132 5564 0   0 25 0  0  0  0  0 18  0  0 131 231 116  4 34 62
1 0 1 10124 5412 0   0 37 0  0  0  0  0 22  0  0 166 179 118  1 33 67
1 0 1 10124 5236 0   0 24 0  0  0  0  0 14  0  0 109 243 113  4 56 39

示例%

vmstat 显示的字段为

kthr

报告以下三个中每一个的内核线程数 状态:

r

    the number of kernel threads in run queue
b

    the number of blocked kernel threads that are waiting for
    resources I/O,paging,and so forth
w

    the number of swapped out lightweight processes (LWPs) that
    are waiting for processing resources to finish.

memory

报告虚拟内存和实内存的使用情况。

swap

    available swap space (Kbytes)
free

    size of the free list (Kbytes)

page

报告有关页面错误和分页活动的信息。这 以下每项活动的信息以每个单位提供 第二个。

re

    page reclaims — but see the –S option for how this field is modified.
mf

    minor faults — but see the –S option for how this field is modified.
pi

    kilobytes paged in
po

    kilobytes paged out
fr

    kilobytes freed
de

    anticipated short-term memory shortfall (Kbytes)
sr

    pages scanned by clock algorithm

当在一个区域中执行并且池工具处于活动状态时,所有 以上(“de”除外)仅报告处理器的活动 区域池的处理器集。

disk

报告每秒磁盘操作数。有插槽 最多四个磁盘,标有一个字母和数字。信 表示磁盘类型(s = SCSI,i = IPI,等等);这 number 是逻辑单元号。

faults

报告陷阱/中断率(每秒)。

in

    interrupts
sy

    system calls
cs

    CPU context switches

当在一个区域中执行并且池工具处于活动状态时,所有 以上仅报告处理器集中处理器的活动 区域的池。

cpu

提供 CPU 时间使用百分比的细分。在 MP 系统上,这 是所有处理器的平均值。

us

    user time
sy

    system time
id

    idle time

当在一个区域中执行并且池工具处于活动状态时,所有 以上仅报告处理器集中处理器的活动 区域的池。

,

这可以帮助您https://www.howtogeek.com/424334/how-to-use-the-vmstat-command-on-linux/。那些短裤有说明。

内存

swpd: the amount of virtual memory used. In other words,how much memory has been swapped out.,free: the amount of idle (currently unused) memory.
buff: the amount of memory used as buffers.
cache: the amount of memory used as cache.

交换

si: Amount of virtual memory swapped in from swap space.
so: Amount of virtual memory swapped out to swap space.

IO

bi: Blocks received from a block device. The number of data blocks used to swap virtual memory back into RAM.
bo: Blocks sent to a block device. The number of data blocks used to swap virtual memory out of RAM and into swap space.

系统

in: The number of interrupts per second,including the clock.
cs: The number of context switches per second. A context switch is when the kernel swaps from system mode processing into user mode processing.
,

“0”不是有效的可用内存值。

按照设计,Solaris 始终确保可用的可用内存量最少。 sr 列也为零的事实表明不存在内存短缺。在任何情况下,如果 RAM 严重不足,您一开始就无法运行 vmstattop

您应该进一步调查以了解为什么报告空闲内存为零。 mdb::memstat 命令将是一个好的开始:

# echo "::memstat" | mdb -k