这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

8 proc.mem 监控项中memtype参数类型的注意事项

概述

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

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

AIX

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

支持值 说明 procentry64结构中来源 尽量兼容
vsize 1 虚拟内存大小 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

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.

  1. 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.

  2. 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>]

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.

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 进程大小 (代码 + 数据 + 堆栈) 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

Linux

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

支持值 描述 来源/proc/<pid>/status 文件
vsize 1 虚拟内存大小 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, pteswap 等值。
  2. 我们发现 Zabbix agent 主动检查进程参数proc.mem[...,...,...,...,data] 显示的值比agent 的 /proc/<pid>/status 文件中 VmData行的值大 4 kB。在agent自我监控管理时,agent的数据碎片增长率4 kB ,然后又返回到先前的值。

Solaris

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

支持值 描述 psinfo 结构中的源代码 兼容
vsize 1 过程映像的大小 pr_size ps -o vsz
pmem 实际内存百分比 pr_pctmem ps -o pmem
rss 驻留集大小
可能被低估了 - 请参阅“man ps”中的 rss 描述。
pr_rssize ps -o rss
注释批注

1 默认值