Skip to content

Instantly share code, notes, and snippets.

@rduplain
Created January 23, 2012 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rduplain/1665892 to your computer and use it in GitHub Desktop.
Save rduplain/1665892 to your computer and use it in GitHub Desktop.
Fast recipe for memory monitoring.

First step toward Nagios: Fast recipe for memory monitoring.

You have a Linux box. It has RAM. You'd like to log and monitor memory usage. You have many options -- here's one: use a check_mem plugin for Nagios, but use it stand-alone at first. You'll have detailed memory logging in just a minute, and will take your first step toward full system monitoring with Nagios (later when you can formally install the plugin).

Download: https://raw.github.com/justintime/nagios-plugins/master/check_mem/check_mem.pl

Read it and make sure you feel comfortable running it. Then chmod a+x check_mem.pl and see help with ./check_mem.pl -h. In one shell, run it in a 5s loop, logging to /tmp/mem.log (Control-C to stop):

while [ 1 ]; do date | tee -a /tmp/mem.log; ./check_mem.pl -u -w 60 -c 90 | tee -a /tmp/mem.log; sleep 5; done

If you'd like to see the memory log in more than one place (even as another user), you can watch the log:

tail -F /tmp/mem.log

Of course, this is a temporary solution. Next, unbox Nagios and work toward getting a graph like this: http://sysadminsjourney.com/content/2009/06/04/new-and-improved-checkmempl-nagios-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment