Linux – Which plugin to use for checking Linux Memory

linuxnagios

Searching for Nagios plugins that checks for memory usage on gives a lot of results, so it is hard to know which to use, as the Nagios plugin package doesn't contain a plugin for checking memory.

So I was wondering, which others are using?

I am using NRPE with Nagios on Linux for Linux hosts.

Best Answer

I disagree strongly with Glen M - the amount of memory available for cache and buffers is essential to ensuring good performance on nearly every type of application on nearly every type of server OS.

If you wait until your webserver starts paging before you know about the problem then it's much too late.

On a handy workstation, I can see this:

             total       used       free     shared    buffers     cached
Mem:       4135700    2588568    1547132          0      91024    2309052
-/+ buffers/cache:     188492    3947208
Swap:      4192944        156    4192788

I'd want to report usage as 100*[used-buffers/cache]/total, or 100*188492/4135700.

Writing a plugin for this is not exactly taxing. But there are several offerings available which cover this - e.g. check_mem.pl

To build your own, here's a wee hint:

PCTUSED=`free | awk '/^Mem:/ {tot=$2; } /buffers/ { used=$3; } END { print used*100/tot }'`