linuxperlnagiosicinga

How is memory used value derived in check_snmp_mem.pl?


I was configuring icinga2 to get memory used information from one linux client using script at check_snmp_mem.pl . Any idea how the memory used is derived in this script ?

Here is free command output

# free
              total        used        free      shared  buff/cache   available
Mem:         500016       59160       89564        3036      351292      408972
Swap:       1048572        4092     1044480

where as the performance data shown in icinga dashboard is

    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

Solution

  • Looking through the source code, it mentions ram_used for example in this line:

      $n_output .= " | ram_used=" . ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free}-$$resultat{$nets_ram_cache}).";";
    

    This strongly suggests that ram_used is calculated as the difference of the total RAM and the free RAM and the RAM used for cache. These values are retrieved via the following SNMP ids:

    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
    

    I don't know how they correlate to the output of free. The difference in free memory reported by free and to Icinga is 48136, so maybe you can find that number somewhere.