Memory usage calculation for Linux

How is the total memory utilization calculated for a Linux server monitor?

Memory utilization is calculated using the "free" command. The output of this command varies according to the Linux distribution used.

Case 1:
Memory Utilized = ( (Total - Free Memory) / Total * 100 )
where,
Free Memory = ( Total - Used + Buffer + Cache )
Eg:

Free Memory = (16313900 - 7857128 + 203152 + 4381116) = 13041040

Memory Utilized = ( (Total-Free) / Total * 100) = 20.06%

Case 2:
This is applicable when using Linux flavors including Centos/Redhat 7+, Ubuntu 16+ etc. 
Eg:

Total Memory = 16330916     Free Memory = Available Memory = 9157464
Thus, Memory Utilized = ( ( Total - Free Memory ) / Total * 100 )
Memory Utilized = 43.92%


Note: The value obtained can be cross verified with the System Monitor (a default tool present in Linux servers for basic metrics monitoring) output.


Related Articles: