[comment]: # translation:outdated

[comment]: # ({new-098d0431})
# 8 proc.mem 监控项中memtype参数类型的注意事项

[comment]: # ({/new-098d0431})

[comment]: # ({2840c113-2840c113})
#### 概述

Linux, AIX, FreeBSD 和 Solaris 都支持**memtype**参数。

'memtype' 参数的三个常用值  `pmem`,  `rss`  和  `vsize`在所有系统中都适用。另外, 在一些系统中只支持该系统下的 'memtype' 值。

[comment]: # ({/2840c113-2840c113})

[comment]: # ({c30765ae-04a03696})
#### AIX

请参阅表中 AIX 上“memtype”参数支持的值。

|支持值|说明|procentry64结构中来源|尽量兼容|
|--|------|--|--|
|vsize ^[1](proc_mem_notes#footnotes)^|虚拟内存大小|pi\_size| |
|pmem|实际内存百分比|pi\_prm|ps -o pmem|
|rss|常驻集大小|pi\_trss + pi\_drss|ps -o rssize|
|size|进程大小（代码 + 数据）|pi\_dvm|“ps gvw”SIZE column|
|dsize|数据大小|pi\_dsize|<|
|tsize|文本（代码）大小|pi\_tsize|“ps gvw” TSIZ column|
|sdsize|共享库的数据大小|pi\_sdsize|<|
|drss|数据常驻集大小|pi\_drss| |
|trss|文本常驻集大小|pi\_trss| |

[comment]: # ({/c30765ae-04a03696})

[comment]: # ({new-d1d61498})

Notes for AIX:

1. When choosing parameters for proc.mem[] item key on AIX, try to specify narrow process selection criteria. Otherwise there is a risk of getting unwanted processes counted into proc.mem[] result.

Example:
```
\$ zabbix_agentd -t proc.mem[,,,NonExistingProcess,rss]
proc.mem[,,,NonExistingProcess,rss]           [u|2879488]
```

This example shows how specifying only command line (regular expression to match) parameter results in Zabbix agent self-accounting - probably not what you want.

[comment]: # ({/new-d1d61498})

[comment]: # ({new-a40c9721})
2. Do not use "ps -ef" to browse processes - it shows only non-kernel processes. Use "ps -Af" to see all processes which will be seen by Zabbix agent.

3. Let's go through example of 'topasrec' how Zabbix agent proc.mem[] selects processes.

```
\$ ps -Af | grep topasrec
root 10747984        1   0   Mar 16      -  0:00 /usr/bin/topasrec  -L -s 300 -R 1 -r 6 -o /var/perf daily/ -ypersistent=1 -O type=bin -ystart_time=04:08:54,Mar16,2023
```

proc.mem[] has arguments:

```
proc.mem[<name>,<user>,<mode>,<cmdline>,<memtype>]
```

[comment]: # ({/new-a40c9721})

[comment]: # ({new-9ec5e875})

The 1st criterion is a process name (argument <name>). In our example Zabbix agent will see it as 'topasrec'. In order to match, you need to either specify 'topasrec' or to leave it empty.
The 2nd criterion is a user name (argument <user>). To match, you need to either specify 'root' or to leave it empty.
The 3rd criterion used in process selection is an argument <cmdline>. Zabbix agent will see its value as '/usr/bin/topasrec -L -s 300 -R 1 -r 6 -o /var/perf/daily/ -ypersistent=1 -O type=bin -ystart_time=04:08:54,Mar16,2023'. To match, you need to either specify a regular expression which matches this string or to leave it empty.

Arguments <mode> and <memtype> are applied after using the three criteria mentioned above. 

[comment]: # ({/new-9ec5e875})

[comment]: # ({c2004450-8a700330})
#### FreeBSD

请参见表中FreeBSD上的“memtype”参数支持的值。

|支持的参数值|描述|proentry64 结构中的源代码|兼容|
|---------------|-----------|-------------------------------|---------------------------|
|vsize|虚拟内存大小|kp\_eproc.e\_vm.vm\_map.size or ki\_size|ps -o vsz|
|pmem|实际内存的百分比|calculated from rss|ps -o pmem|
|rss|驻留内存大小|kp\_eproc.e\_vm.vm\_rssize or ki\_rssize|ps -o rss|
|size ^[1](proc_mem_notes#footnotes)^|进程大小 (代码 + 数据 + 堆栈)|tsize + dsize + ssize|<|
|tsize|文本(代码)的大小|kp\_eproc.e\_vm.vm\_tsize or ki\_tsize|ps -o tsiz|
|dsize|数据大小|kp\_eproc.e\_vm.vm\_dsize or ki\_dsize|ps -o dsiz|
|ssize|堆栈大小|kp\_eproc.e\_vm.vm\_ssize or ki\_ssize|ps -o ssiz|

[comment]: # ({/c2004450-8a700330})

[comment]: # ({9164d2d0-f43d1dfd})
#### Linux

请参见表中Linux上的“memtype”参数支持的值。

|支持值|描述|来源/proc/<pid>/status 文件|
|---------------|-----------|---------------------------------------|
|vsize ^[1](proc_mem_notes#footnotes)^|虚拟内存大小|VmSize|
|pmem|实际内存百分比|(VmRSS/total\_memory) \* 100|
|rss|驻留内存大小|VmRSS|
|data|数据段大小|VmData|
|exe|代码段大小|VmExe|
|hwm|驻留集峰值大小|VmHWM|
|lck|锁定内存大小|VmLck|
|lib|共享库的大小|VmLib|
|peak|峰值虚拟内存大小|VmPeak|
|pin|固定页面的大小|VmPin|
|pte|页表条目的大小|VmPTE|
|size|进程代码 + 数据 + 堆栈段的大小|VmExe + VmData + VmStk|
|stk|堆栈段大小|VmStk|
|swap|使用的交换空间大小|VmSwap|

Linux上注意事项:

1.  一些旧版本Linux 内核并不是支持所有'memtype' 值的。例如, Linux 内核版本2.4就不支持  `hwm`,  `pin`,  `peak`,  `pte`  和  `swap`  等值。
2.  我们发现 Zabbix agent 主动检查进程参数`proc.mem[...,...,...,...,data]`  显示的值比agent 的 /proc/<pid>/status 文件中  `VmData`行的值大 4 kB。在agent自我监控管理时，agent的数据碎片增长率4 kB ，然后又返回到先前的值。

[comment]: # ({/9164d2d0-f43d1dfd})

[comment]: # ({d8c5e366-96fd9f28})
#### Solaris

请参见表中的Solaris上的“memtype”参数所支持的值。

|支持值|描述|psinfo 结构中的源代码|兼容|
|---------------|-----------|--------------------------|---------------------------|
|vsize ^[1](proc_mem_notes#footnotes)^|过程映像的大小|pr\_size|ps -o vsz|
|pmem|实际内存百分比|pr\_pctmem|ps -o pmem|
|rss|驻留集大小<br>可能被低估了 - 请参阅“man ps”中的 rss 描述。|pr\_rssize|ps -o rss|

[comment]: # ({/d8c5e366-96fd9f28})

[comment]: # ({e0ce8129-e0ce8129})
##### 注释批注

^**1**^ 默认值

[comment]: # ({/e0ce8129-e0ce8129})
