0

I wish to setup monitoring alerts upon used memory percentage.

I had setup 0-80% used RAM as Green (good) 81-90% as yellow(acceptable) 91-95% as orange(warning) 96+ as Red(critical)

However, i see that my current usage of RAM is 99% yet everything seems working smoothly and that makes everyone feel 96+ as Red(critical) is not the right criteria to Alert for critical.

I noticed that despite 99% usage of RAM the swap memory was 100% free.

$ free -m
              total        used        free      shared  buff/cache   available
Mem:          15883        1672         273          57       13938       13766
Swap:          2047           0        2047

Thus, my query is should I also check for swap memory or only the swap memory to send out Alerts and what would that appropriate threshold be for RAM as well as swap memories ?

Ashar
  • 449
  • 3
  • 10
  • 26
  • Your `free` output shows 10.5% memory used, not 99%. It also shows less than 1% free, but for your purposes I suspect that the “used” value is more appropriate. (A general answer would depend on your exact workloads, which is why I’m only commenting.) – Stephen Kitt Oct 07 '21 at 10:28
  • Also note that with the extensive caching in modern OSes (and some applications), your monitoring carries less actual meaning than you might be tempted to think. So what does it mean if your computer uses 10% for kernel and process data, and 89% for caches? It means that if anyone needs more memory, they will get it, without needing to use swap. Cool. And if these caches are slowly used read caches, this has no downside; you probably won't notice the resulting performance difference. – Marcus Müller Oct 07 '21 at 11:55
  • If these are very frequently used, highly active read/write caches in a storage-centric system, then taking away from the 89% will make your system suddenly become much much slower, even if you just are using 20% instead of 10% of your RAM for process memory. – Marcus Müller Oct 07 '21 at 11:56

1 Answers1

1

You are confused between free and available. free stand for memory actually empty (nothing there). available is the amount you left to use, you can load stuff here. buff/cache are disk cache, recently used files, stuff to be written to disk and such. Things of disk currently residing on memory. Most of the memory is accounted to them. Caches can be emptied any time. They are expandable. If you need to load some library you can always flush the cache. But on the other hand, they give serious boost to I/O. Accessing files from memory is lots faster than from fastest SSDs. So it is a win-win. Here is man free (ok, it is of Linux, OpenSolaris online man doesn't expalain)

       used   Used memory (calculated as total - free - buffers - cache)

       available
              Estimation  of  how much memory is available for starting new applications, without
              swapping. Unlike the data provided by the cache or free fields,  this  field  takes
              into  account page cache and also that not all reclaimable memory slabs will be re-
              claimed due to items being in use (MemAvailable in /proc/meminfo, available on ker-
              nels 3.14, emulated on kernels 2.6.27+, otherwise the same as free)

Remember memory unused is memory wasted.

Abdullah Ibn Fulan
  • 1,190
  • 4
  • 19