Page 1 of 1

Linux Memory Utilization

Posted: Wed Apr 19, 2017 8:15 am
by steelwedge
Hi Support,

We are finding difficult to capture actual memory usage from Linux boxes that are monitored by Nagios using SNMP.

Our requirement is to get actual memory usage excluding cache/buffer. Appreciate your inputs in this matter.

Many Thanks,
Abdul Rahman

Re: Linux Memory Utilization

Posted: Wed Apr 19, 2017 10:39 am
by cdienger
Hi steelwedge,

You may want to try polling some additional OID's to get memory stats:

Total Swap Size: .1.3.6.1.4.1.2021.4.3.0
Available Swap Space: .1.3.6.1.4.1.2021.4.4.0
Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0
Total RAM used: .1.3.6.1.4.1.2021.4.6.0
Total RAM Free: .1.3.6.1.4.1.2021.4.11.0
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0


There may also be some better suited snmp plugins available on exchange.nagios.com. https://exchange.nagios.org/directory/P ... ry/details is a bash script that may give you what you need as well.

Re: Linux Memory Utilization

Posted: Mon Apr 24, 2017 5:40 am
by elinagios
Hello

We have the exact same problem, finding out real memory usage with XI for Linux via SNMP seems to be an impossible job. The bash script given doesn't suit, no way to define any host, community and so on. Would like a solution for this also.
Can you describe what the current XI memory checks for Linux SNMP actually monitor, i havent found out what is that they add/divide (buffers, cache, used, free)

Nagios XI wizard (Linux SNMP)
Physical Memory Usage (Run without buffers) ?
Physical Memory Usage (Run with buffers) ?

Regards,
Mirgo

Re: Linux Memory Utilization

Posted: Mon Apr 24, 2017 11:15 am
by mcapra
Here's the logic behind the with buffers/without buffers in terms of the plugin's execution:

Code: Select all

if ($services['nobuffers'] == 'on') {
                $nobuffers = 'Physical';
            } else {
                $nobuffers = 'Memory';
            }
And here's the verbose output from that plugin with the respective options:

Code: Select all

[root@xi-stable ~]# /usr/local/nagios/libexec/check_snmp_storage_wizard.pl -H 192.168.67.105  -C welcome2 --v2c -m Memory -w 80 -c 90 -f -v
Alarm at 15
SNMP v2c login
Filter : Memory
OID : 1.3.6.1.2.1.25.2.3.1.3.3, Desc : Virtual memory
OID : 1.3.6.1.2.1.25.2.3.1.3.10, Desc : Swap space
OID : 1.3.6.1.2.1.25.2.3.1.3.8, Desc : Shared memory
OID : 1.3.6.1.2.1.25.2.3.1.3.57, Desc : /boot
OID : 1.3.6.1.2.1.25.2.3.1.3.39, Desc : /sys/fs/cgroup
OID : 1.3.6.1.2.1.25.2.3.1.3.6, Desc : Memory buffers
   Name : Memory buffers, Index : 6
OID : 1.3.6.1.2.1.25.2.3.1.3.1, Desc : Physical memory
OID : 1.3.6.1.2.1.25.2.3.1.3.38, Desc : /run
OID : 1.3.6.1.2.1.25.2.3.1.3.36, Desc : /dev/shm
OID : 1.3.6.1.2.1.25.2.3.1.3.7, Desc : Cached memory
OID : 1.3.6.1.2.1.25.2.3.1.3.31, Desc : /
storages selected : 1
1.3.6.1.2.1.25.2.3.1.4.6  : 1024
1.3.6.1.2.1.25.2.3.1.6.6  : 948
1.3.6.1.2.1.25.2.3.1.5.6  : 3882428
Descr : Memory buffers
Size :  3882428
Used : 948
Alloc : 1024
Perf data : 'Memory_buffers'=1MB;3033;3412;0;3791
Memory buffers: 0%used(1MB/3791MB) (<80%) : OK | 'Memory_buffers'=1MB;3033;3412;0;3791

...

[root@xi-stable ~]# /usr/local/nagios/libexec/check_snmp_storage_wizard.pl -H 192.168.67.105  -C welcome2 --v2c -m Physical -w 80 -c 90 -f -v
Alarm at 15
SNMP v2c login
Filter : Physical
OID : 1.3.6.1.2.1.25.2.3.1.3.3, Desc : Virtual memory
OID : 1.3.6.1.2.1.25.2.3.1.3.10, Desc : Swap space
OID : 1.3.6.1.2.1.25.2.3.1.3.8, Desc : Shared memory
OID : 1.3.6.1.2.1.25.2.3.1.3.57, Desc : /boot
OID : 1.3.6.1.2.1.25.2.3.1.3.39, Desc : /sys/fs/cgroup
OID : 1.3.6.1.2.1.25.2.3.1.3.6, Desc : Memory buffers
OID : 1.3.6.1.2.1.25.2.3.1.3.1, Desc : Physical memory
   Name : Physical memory, Index : 1
OID : 1.3.6.1.2.1.25.2.3.1.3.38, Desc : /run
OID : 1.3.6.1.2.1.25.2.3.1.3.36, Desc : /dev/shm
OID : 1.3.6.1.2.1.25.2.3.1.3.7, Desc : Cached memory
OID : 1.3.6.1.2.1.25.2.3.1.3.31, Desc : /
storages selected : 1
1.3.6.1.2.1.25.2.3.1.5.1  : 3882428
1.3.6.1.2.1.25.2.3.1.6.1  : 680560
1.3.6.1.2.1.25.2.3.1.4.1  : 1024
Descr : Physical memory
Size :  3882428
Used : 680560
Alloc : 1024
Perf data : 'Physical_memory'=665MB;3033;3412;0;3791
Physical memory: 18%used(665MB/3791MB) (<80%) : OK | 'Physical_memory'=665MB;3033;3412;0;3791
So as far as the plugin is concerned, it's just a difference in which OID is used. How those OIDs are calculated is sort of beyond the scope of the plugin itself, but there's some documentation on the main net-snmp page:
http://www.net-snmp.org/docs/mibs/host.html

And I think the github probably contains the calculations buried in the source somewhere:
https://github.com/haad/net-snmp

Re: Linux Memory Utilization

Posted: Wed Apr 26, 2017 7:22 am
by elinagios
So the idea is to start changing the OID in check_snmp_storage_wizard.pl? Why not make a memory check that gives out used memory on linux side via SNMP. At the moment this check doesn't help much.
Or try to use some other memory check and replace it in the Linux SNMP wizzard?

Re: Linux Memory Utilization

Posted: Wed Apr 26, 2017 11:39 am
by cdienger
The values that are available via snmp are completely dependent on the host so making a one size fits all wizard is difficult. You do not need to specify the OID number though, you can use the description OID(http://nagios.manubulon.com/snmp_storage.html) with -m:

-m, --name=NAME
Name in description OID (can be mounpoints '/home' or 'Swap Space'...)
This is treated as a regexp : -m /var will match /var , /var/log, /opt/var ...
Test it before, because there are known bugs (ex : trailling /)


For example, the default memory checks use:

-C public --v2c -m Physical -w 80 -c 90 -f (run without buffers)
-C public --v2c -m Memory -w 80 -c 90 -f (run with buffers)