我正在配置 icinga2 以使用 check_snmp_mem 处的脚本从一个 Linux 客户端获取内存使用信息。 .pl。知道这个脚本中使用的内存是如何导出的吗?
这是免费的命令输出
# free
total used free shared buff/cache available
Mem: 500016 59160 89564 3036 351292 408972
Swap: 1048572 4092 1044480
icinga 仪表板中显示的性能数据是
Label Value Max Warning Critical
ram_used 137,700.00 500,016.00 470,015.00 490,016.00
swap_used 4,092.00 1,048,572.00 524,286.00 838,858.00
查看源代码,它在这一行中提到了ram_used
:
$n_output .= " | ram_used=" . ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free}-$$resultat{$nets_ram_cache}).";";
这强烈表明,ram_used
的计算方式是总 RAM 和空闲 RAM 以及用于缓存的 RAM 之差。这些值通过以下 SNMP ID 检索:
my $nets_ram_free = "1.3.6.1.4.1.2021.4.6.0"; # Real memory free
my $nets_ram_total = "1.3.6.1.4.1.2021.4.5.0"; # Real memory total
my $nets_ram_cache = "1.3.6.1.4.1.2021.4.15.0"; # Real memory cached
我不知道它们与free
的输出有何关联。 free
报告的可用内存与 Icinga 报告的可用内存差异为 48136,因此也许您可以在某处找到该数字。
我是一名优秀的程序员,十分优秀!