Unix Memory Usage Monitoring Via SNMP and Nagios


Using SNMP to monitor memory usage in UNIX can be somewhat of a complex task. As you may already know about me, I’m a very simple guy and I don’t like anything complex. With SNMP, if I want to monitor the memory usage on any UNIX server, I want to be able to run a simple SNMP command and get back exactly what I want from that one SNMP command. But sadly, there is no tool like that readily available. Which is why, I wrote my own SNMP memory tool.

But why did I really have to write my own tool?

See, if Joe Schmoe wants to know how much memory is installed on a remote server and how much of that installed memory is being used overall, he’s got nothing to use to help him get that information. He’s going to have to use a combination of UNIX tools to gather & grab the SNMP data that he needs and then start to analyze and compute the correct numbers from that data.

Having to do this type of work on a regular basis is insanely tedious. Which is why I spent days (yes that’s right), writing an SNMP memory tool that does all the required work for me.

The only absolute thing this SNMP memory tool needs in order to function as designed is for the SNMP program to be installed on the local server and the SNMP process to be running on remote server that you’re inquiring memory information about.

If SNMP isn’t running on that remote server or if the running SNMP version is quite old and outdated, then you’ll run into issues. Your issues will be quickly fixed once you upgrade the remote server’s SNMP.

So how does this SNMP script really work? See the below:

SYNTAX: SNMP_memory_check (community-string) (remote-server) (OID) (warning) (critical)



[prod.ke0:538] SNMP_memory_check AFA@%FG s20.ke0.m.blah.net UCD-SNMP-MIB::memory 90 95

OK: Total Memory: [ 7.81055 GB ]. Total Free Memory: [ 7.56934 GB ]. Current Usage: [ 3.08592% ]. Thresholds: [ W=(90%) / C=(95%) ]. Buffer [ 2.43066 GB ]. Cached [ 4.01953 GB ].






[prod.ke0:538] SNMP_memory_check AFA@%FG s20.ke0.m.blah.net UCD-SNMP-MIB::memory 50 80

WARNING: Memory usage has breached the [ Warning(50%) ] threshold. Current Usage = [ 58.0855% ] with [ 4.91504 GB ] memory left. Memory Installed = [ 11.7256 GB ]. Buffer [ 667.148 MB ]. Cached [ 785.996 MB ].




Explanation of Each Parameter:

SNMP_memory_check = Tool Name

AFA@%FG = Community String

S20.ke0.m.blah.net = The Remote Server


30 = Warning

90 = Critical

This script works on both Linux and Sun Solaris servers. If you have Nagios installed in your environment, you can use it to alert and to send out email notifications.

As long as the OS running on the remote server you’re inquiring about is Linux or Solaris, this script will save you hours, days or even weeks of headaches.


In order to be able to write a SNMP script like the one above or download one like it, this is what you need to have:

1. SNMP installed on your local server (the server you will be running the command from).

2. SNMP running on the remote server (the server you will be inquiring memory information about).

3. Know the community string of the SNMP on the remote server.


Leave a Reply