7

Once can have monit monitor memory usage…

check system foo
  if memory usage > 95% then alert

Does it use free RAM, or free -/+ buffers/cache? (or something else?)

# free -m
             total       used       free     shared    buffers     cached
Mem:           998        851        146          0        114         70
-/+ buffers/cache:        666        332
Swap:         2047         54       1993
John Bachir
  • 2,364
  • 7
  • 29
  • 37

3 Answers3

6

This could be get from the source of monit https://github.com/arnaudsj/monit/tree/master/process.

For linux the value is computed in sysdep_LINUX.c and comes from /proc/meminfo :

si->total_mem_kbyte = systeminfo.mem_kbyte_max - mem_free - buffers - cached;

In other words monit use as memory usage MemTotal - MemFree - Buffers - Cached.

In your case 998 - 146 - 114 - 70 = 668

mpromonet
  • 134
  • 1
  • 12
1

On latest Monit (ie: 5.25.x) the memory usage value accounts for ZFS ARC cache - so if someout is using ZFS, used memory is not ballooned by reclaimable ARC data.

Current memory usage is calculated as:

si->memory.usage.bytes = systeminfo.memory.size - zfsarcsize -
(uint64_t)(mem_free + buffers + cached + slabreclaimable) * 1024;

See here from more details.

shodanshok
  • 47,711
  • 7
  • 111
  • 180
-1

AFAIK, it based on:

used memory - cached = 851 - 70 = 781
quanta
  • 51,413
  • 19
  • 159
  • 217