Skip to content

Nagios Plugin check_memory

Davide Madrisan edited this page Dec 18, 2016 · 2 revisions

check_memory - check the memory usage

[/etc/nrpe.d/check_memory]
command[check_memory]=/usr/lib/nagios/plugins/check_memory -b -w 85% -c 95%
Usage note
This plugin checks the system memory utilization.
Copyright (C) 2014,2015 Davide Madrisan <davide.madrisan@gmail.com>

Usage:
  check_memory [-a] [-b,-k,-m,-g] [-s] -w PERC -c PERC

Options:
  -a, --available display the free/available memory
  -b,-k,-m,-g     show output in bytes, KB (the default), MB, or GB
  -s, --vmstats   display the virtual memory perfdata
  -w, --warning PERCENT   warning threshold
  -c, --critical PERCENT   critical threshold
  -h, --help      display this help and exit
  -V, --version   output version information and exit

Note:
  The option '-a|--available' gives an estimation of the available memory
  for starting new applications without swapping.
  It requires at least a kernel 3.14, which provides this information in
  /proc/meminfo (see the parameter 'MemAvailable').
  A MemAvailable fall-back code is implemented for kernels 2.6.27 and above.
  For older kernels 'MemFree' is returned instead.

Examples:
  check_memory --available -w 20%: -c 10%:
  check_memory --vmstats -w 80% -c90%
Example of output
> /usr/lib/nagios/plugins/check_memory --available -w 20%: -c 10%: 
memory OK: 38.67% (6336532 kB) available | mem_total=16384256kB mem_used=8658532kB mem_free=725892kB mem_shared=1135788kB mem_buffers=540432kB mem_cached=6459400kB mem_available=6336532kB mem_active=10584516kB mem_anonpages=8350928kB mem_committed=21568488kB mem_dirty=124kB mem_inactive=4351820kB

> /usr/lib/nagios/plugins/plugins/check_memory --vmstats -w 80% -c90%
memory OK: 52.84% (8657424 kB) used | mem_total=16384256kB mem_used=8657424kB mem_free=722972kB mem_shared=1139524kB mem_buffers=540580kB mem_cached=6463280kB mem_available=6333900kB mem_active=10581364kB mem_anonpages=8347792kB mem_committed=21565120kB mem_dirty=152kB mem_inactive=4355724kB, vmem_pageins/s=0, vmem_pageouts/s=72, vmem_pgmajfault/s=0
Performance data
  • mem_total: Total usable physical RAM
  • mem_used: Total amount of physical RAM used by the system
  • mem_free: Amount of RAM that is currently unused
  • mem_shared: Now always zero; not calculated
  • mem_buffers: Amount of physical RAM used for file buffers
  • mem_cached: In-memory cache for files read from the disk (the page cache)
  • mem_available: kernel >= 2.6.27: memory available for starting new applications, without swapping
  • mem_available: _kernel < 2.6.27: same as mem_free
  • mem_active: Memory that has been used more recently
  • mem_anonpages: Non-file backed pages mapped into user-space page tables
  • mem_committed: The amount of memory presently allocated on the system
  • mem_dirty: Memory which is waiting to get written back to the disk
  • mem_inactive: Memory which has been less recently used
  • vmem_pageins, vmem_pageouts: The number of memory pages the system has written in and out to disk
  • vmem_pgmajfault: The number of memory major pagefaults
Documentation

A good article on the subject: Understanding and optimizing Memory utilization