Page 1 of 2

how to exclude the Linux cached memory from the monitoring a

Posted: Tue Jun 11, 2019 4:49 am
by vivma1989
We are using GItHub Enterprise as our source code management system and its installed as an appliance in Vmware Esxi.

This has primary and replica servers located in 2 data centers also.

For monitoring purpose we are using Nagios over SNMP for getting the performance metrics.

Nagios over SNMP ( GHE provides the resource metric by default over SNMP) we enabled SNMPV3 from GHE appliance side


But its noticed that GHE will create a much cached memory which will result in unwanted alerts. There is 4.6 G of cached memory, how to configure Nagios to alert the threshold for GHE (used-cached) memory instead of just used memory.

Current memory usage on the system is:

free -h

total used free shared buffers cached Mem:
15G 14G 909M 1.5M 375M 4.6G
-/+ buffers/cache: 9.8G 5.9G
Swap: 0B 0B 0B

But in Nagios side is there any way to exclude these linux consumed memory and only the GHE consumed memory alone?

Re: how to exclude the Linux cached memory from the monitori

Posted: Tue Jun 11, 2019 3:16 pm
by npolovenko
Hello, @vivma1989. What plugin and command are you currently using to check the memory?
This plugin should exclude cached memory by default:

Code: Select all

/usr/local/nagios/libexec/check_snmp_mem.pl -H 192.168.3.3 -C communityString  -w 80,80 -c 90,90
http://nagios.manubulon.com/snmp_mem.html

Re: how to exclude the Linux cached memory from the monitori

Posted: Tue Jun 11, 2019 11:10 pm
by vivma1989
Thanks for your quick reply.. I will check this and let u know. But We have enabled SNMP V3 and in that case how the command should be executed for this plugin?

Re: how to exclude the Linux cached memory from the monitori

Posted: Wed Jun 12, 2019 3:27 pm
by npolovenko
@vivma1989, Here's an example of the command for snmp v3:
./check_snmp_storage.pl -H <HOSTNAME> -l <login> -x <password> -X <privPassword> -L SHA, AES -q Ram -m Physical -w 10 -c 5 0

Code: Select all

-l, --login=LOGIN ; -x, --passwd=PASSWD; -X=Priv password for snmpv3 (AuthPriv protocol); -L, --protocols=<authproto>,<privproto>;  -q, --storagetype=[Other|Ram|VirtualMemory|FixedDisk|RemovableDisk|FloppyDisk
CompactDisk|RamDisk|FlashMemory|NetworkDisk]
*If arguments -l and -x not provided, the plugin will assume AuthNoPriv.

http://nagios.manubulon.com/snmp_mem.html

Re: how to exclude the Linux cached memory from the monitori

Posted: Mon Jun 17, 2019 5:54 am
by vivma1989
We tried this, But, its calculating full used memory.

./check_snmp_storage.pl -H xx.xx.xx.xx --login=xxxxx --passwd=xxxx --privpass=xxxxx --protocols=sha,aes -q Ram -m Physical -w 90 -c 95 -f

Physical memory: 93%used

But we are looking for only used memory excluding the cache memory.

(used-available)
_____________
Total

Re: how to exclude the Linux cached memory from the monitori

Posted: Mon Jun 17, 2019 11:39 am
by npolovenko
@vivma1989, Please try the check_snmp_mem.pl plugin instead.
http://nagios.manubulon.com/snmp_mem.html

Code: Select all

[root@centos7x64 libexec]# ./check_snmp_mem.pl  -H localhost  -l nagios -x qwerty12345 -m -w 80,80 -c 90,90 -v
Ram : 1965708 / 3882040 : 49
Swap : 2036672 / 2097148 : 3
Ram : 49%, Swap : 3% : ; OK

[root@centos7x64 libexec]# ./check_snmp_mem.pl  -H localhost  -l nagios -x qwerty12345 -m -w 80,80 -c 90,90
Ram : 50%, Swap : 3% : ; OK

[root@centos7x64 libexec]# free -h
              total        used        free      shared  buff/cache   available
Mem:           3.7G        834M        1.9G        184M        1.0G        2.4G
Swap:          2.0G         59M        1.9G

Re: how to exclude the Linux cached memory from the monitori

Posted: Tue Jun 18, 2019 1:04 am
by vivma1989
Tried, but again wrong result

check_snmp_mem.pl -H XXXXX --login=XXXXX --passwd=XXXXX --privpass=XXXXX --protocols=sha,aes -m -w 90,90 -c 95,95 -v
Alarm at 15
SNMPv3 AuthPriv login : XXXXX, sha, aes
Ram : 526920 / 16437176 : 97
Swap : 0 / 0 : 0
Ram : 97%, Swap : 0% : > 95, 95 ; CRITICAL

its again showing as 97 % , which is not correct( its again including the cache memory in the used memory)

free
total used free shared buff/cache available
Mem: 16437176 11679836 771992 5100 3985348 4413996
Swap: 0 0 0



Note:- I think, in your example also, its showing wrong details.

linux will treat cache memory as used memory and in order to get the application consumed memory:-

We have to get the value in way like

(used memory - available memory)
________________________________ * 100

(Total memory)

But in your example also its not showing correct values.. Please read this.. https://www.linuxatemyram.com/

please correct me if i am wrong with my statement....

or is there any way to exclude the cache memory from the monitoring ?

Re: how to exclude the Linux cached memory from the monitori

Posted: Tue Jun 18, 2019 3:54 pm
by npolovenko
@vivma1989, It's odd that the plugin is showing 97 even though 526920 is not 97% of 16437176. I also agree that it would make sense to take the available memory into consideration when calculating used memory. Unfortunately, this plugin wasn't developed by Nagios so I'd suggest raising both issues on the authors GitHub page.
https://github.com/dnsmichi/manubulon-snmp/issues/new

Can you run the command without -m. For example(with -m):

Code: Select all

[root@centos7x64 libexec]# ./check_snmp_mem.pl  -H localhost  -l nagios -x qwerty12345 -m -w 80,80 -c 90,90
Ram : 55%, Swap : 3% : ; OK
But without -m:

Code: Select all

[root@centos7x64 libexec]# ./check_snmp_mem.pl  -H localhost  -l nagios -x qwerty12345 -w 80,80 -c 90,90
Ram : 32%, Swap : 3% : ; OK

Re: how to exclude the Linux cached memory from the monitori

Posted: Wed Jun 19, 2019 5:50 am
by vivma1989
not helped in any of the ways. :cry:

checked both the ways:

1) with -m

/check_snmp_mem.pl -H xxxxx --login=xxxxxx --passwd=xxxxx --privpass=xxxxx --protocols=sha,aes -m -w 90,90 -c 95,95 -f

Ram : 93%, Swap : 0% : > 90, 90 ; WARNING | ram_used=15360688;14793458;15615317;0;16437176 swap_used=0;0;0;0;0

I think, here its calculating as

(used+ cache)
__________________ * 100
Total



2) without -m

/check_snmp_mem.pl -H xxxxx --login=xxxxx --passwd=xxxxx --privpass=xxxxx --protocols=sha,aes -w 90,90 -c 95,95 -f

Ram : 75%, Swap : 0% : ; OK | ram_used=12260732;14793458;15615317;0;16437176 swap_used=0;0;0;0;0


Here its calculation is
(used)
________ * 100
Total


But actually we need :

[ (used)-(cache)]
___________________ * 100
Total


Also raised the support request in the shared github site, but they cancelled stating that Nagios side need to check this....
Total

Re: how to exclude the Linux cached memory from the monitori

Posted: Wed Jun 19, 2019 4:43 pm
by lmiltchev
I believe the calculations are done differently... Here's what I see in the code:

Code: Select all

$n_output .= " ; ".$n_status;
  if (defined ($o_perf)) {
    if (defined ($o_cache)) {
      $n_output .= " | ram_used=" . ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free}).";";
    }
    else {
      $n_output .= " | ram_used=" . ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free}-$$resultat{$nets_ram_cache}).";";
    }
    $n_output .= ($o_warnR ==0)? ";" : round($o_warnR * $$resultat{$nets_ram_total}/100,0).";";
The output of the free command:

Code: Select all

# free
             total       used       free     shared    buffers     cached
Mem:       8193052    1832496    6360556        500     185352     856036
-/+ buffers/cache:     791108    7401944
Swap:      2097148          0    2097148
Testing the plugin with and without "-m":

Code: Select all

# /usr/local/nagios/libexec/check_snmp_mem.pl -H 192.168.x.x -C community -2 -m -w 90,90 -c 95,95 -f
Ram : 22%, Swap : 0% : ; OK | ram_used=1834504;7373747;7783399;0;8193052 swap_used=0;1887433;1992291;0;2097148

# /usr/local/nagios/libexec/check_snmp_mem.pl -H 192.168..x.x -C community -2 -w 90,90 -c 95,95 -f
Ram : 12%, Swap : 0% : ; OK | ram_used=978464;7373747;7783399;0;8193052 swap_used=0;1887433;1992291;0;2097148
So, we have:

total - free = 8193052 - 6360556 = 1832496 # with "-m"
total - free - cached = 8193052 - 6360556 - 856036 = 976460 # without "-m"

There is a little difference in numbers but it's probably caused by rounding, and they are "close enough". Does this make sense?