Site icon UnixArena

How to calculate SAR and VMSTAT memory values

Most of the UNIX beginners are very confused with sar and vmstat outputs.In most of the occasion they are not able to determine the free memory and free swap in order to find the memory bottleneck.Not all the time  “top” command will give right values. Ksar graphical tool also very useful to analysis bottleneck.

SAR:
Now we will see how to calculate free memory and swap
Formula:
Free memory in GB= freemem*pagesize/1024/1024/1024
Free swap in GB=freeswap*512/1024/1024/1024
To find the page size value,
[root@wSolarisN ~]# pagesize
8192

FYI:In x86 pagesize value is 4k and in SPARC its 8k.

As per the above commands output,
Free memory in GB =6917436*8192/1024/1024/1024=52.77GB
Free swap in GB=89634194*512/1024/1024/1024=42.74GB
[root@solarisN~]# sar -r 5 5
SunOS SolarisN 5.10 Generic_147440-09 sun4v 03/12/2013
08:16:18 freemem freeswap
08:16:23 6916895 89225128
08:16:28 6918127 89796122
08:16:34 6917438 89645747
08:16:39 6917972 89797936
08:16:45 6916954 89760317
Average 6917436 89634194

VMSTAT:
vmstat will provide the free memory and free swap in KB .So its very easy to calculate unlike the SAR values.

Formula:
Free memory in GB=value/1024/1024
Free swap in GB=value/1024/1024
Free swap in GB=44905096/1024/1024=42.82GB
Free memory in GB=55305768/1024/1024=52.74GB
[root@solarisN ~]# vmstat 5 5
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr m1 m1 m1 m2 in sy cs us sy id
6 0 0 96425064 87221048 18 63 10 0 0 0 0 4 4 4 81 921 923 908 2 0 98
1 0 0 44907344 55306816 1 6 0 0 0 0 0 0 0 0 0 961 1254 954 0 0 99
3 0 0 44854688 55307016 1 1 0 0 0 0 0 0 0 0 0 945 1216 936 0 0 99
13 0 0 44912064 55312408 1 2 0 0 0 0 0 0 0 0 0 944 1221 943 0 0 99
1 0 0 44905096 55305768 1 2 0 0 0 0 0 0 0 0 0 969 1274 966 0 0 99

Thank you for reading this article.Please leave a comment if you have any doubt ,i will get back to you as soon as possible.
Exit mobile version