0

I now understand a bit more RAM usage in linux OS and I knwo that I can use free -h to have correct knowledge about RAM utilization in my server.

but I also have SAR that is working on my server and I don't see the link between SAR outputs and free output.

this website write some relationship between these command outputs but it is not correct for my server. why ? https://www.catalyst2.com/knowledgebase/server-management/investigating-memory-usage-with-sar/

for instance here what I have in same time :

sar -f /var/log/sa/sa04 -r
Linux 3.10.0-1062.4.1.el7.x86_64 (XXXXX)      03/04/2024      _x86_64_        (32 CPU)

Average: kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty 229307171 394 10:15:01 AM 20288408 507419344 96.16 23956 425241152 139210760 25.57 259695284 230272148 148 10:20:01 AM 20105208 507602544 96.19 23956 425232140 139499180 25.62 259847160 230279820 348 10:25:01 AM 21172892 506534860 95.99 23956 425321436 138078624 25.36 258889072 230283168 200 10:30:01 AM 21162780 506544972 95.99 23956 425347776 138069932 25.36 258893704 230280008 216 10:35:01 AM 20702812 507004940 96.08 23956 425471328 139023364 25.53 259269580 230360248 7032 10:40:02 AM 20318412 507389340 96.15 23956 425443164 141154772 25.92 259582372 230358724 1192 10:45:02 AM 19954804 507752948 96.22 23956 425795580 141170648 25.93 259644240 230674360 196 10:50:01 AM 20096560 507611192 96.19 23956 425794692 140834740 25.87 259517620 230666828 204

free -h total used free shared buff/cache available Mem: 503G 75G 19G 1.6G 408G 425G Swap: 15G 666M 15G

it seems that buff/cache value 408G is not equal to kbchached+kbbuffers... kbcached value seems to be equal to "available" output of free.

it is strange. is there a problem in SAR configuration ?

please note that these command are launched in same time and sar refresh is small enough so that RAM usage don't change a lot during the interval.

iostrym
  • 43
  • 1
  • 6

1 Answers1

2

Both sar and free get their information from /proc/meminfo.

man free describes exactly which values from /proc/meminfo correspond to its output.

  • buffers value is Buffers in /proc/meminfo
  • cache value is Cached and SReclaimable in /proc/meminfo
  • buff/cache Sum of buffers and cache

man sar doesn't have such a description but from the source code of rd_stats.c it seems that:

  • kbcached equals Cached
  • kbbuffers equals Buffers.

The difference between sar and free output is in SReclaimable which free counts but sar does not.

AlexD
  • 11,191