Monitoring Free Memory
One thing I’ve always have difficulty keeping straight is what the
free command in Linux tells you about buffers and cache memory. Is
that buffers and cache used and free (making you do the math of how much
real free memory you have) or does the
free command do the math for
you? In tuning a Nagios setup, I researched it to make sure I had it
Misunderstandings about how Linux uses RAM are common and those misconceptions can lead to quite a few false positives in monitoring machines for memory pressure conditions. Linux doesn’t eat RAM, although it will try to use as much RAM as possible to cache block devices which makes your machine much faster.
free does the math for you. Its goal is to inform you about
free memory, not make you do math. :
$ free -m total used free shared buffers cached Mem: 257948 256570 1377 0 3336 238963 -/+ buffers/cache: 14270 243677 Swap: 262127 1 262126
-/+ buffers/cache line’s two values are:
- Buffer/cache memory used subtracted from total used memory.
- Buffer/cache memory used added to total free memory.
More precisely the two values above are calculated like so:
- Total Used Memory - Buffers - Cached
- Total RAM - Value obtained in #1
/proc/meminfo for the gory details.