• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

How to calculate SAR and VMSTAT memory values

March 12, 2013 By Cloud_Devops 13 Comments

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.

Filed Under: Solaris 10, Unix Monitoring tools

Reader Interactions

Comments

  1. Sarangi says

    October 26, 2016 at 1:17 pm

    Hi
    below is the vmstat 1 2 output from non global zone ..my zone system is having only 8GB..then why it is showing free memory as 220739616/1024/1024 =210.5137 GB

    Please help me know the memory calculation in this case

    kthr memory page disk faults cpu
    r b w swap free re mf pi po fr de sr s0 s1 s2 s3 in sy cs us sy id
    0 0 0 222348992 224202896 1561 4572 0 0 0 0 0 0 -0 4 4 10306 73687 15355 19 4 77

    0 0 0 218022328 220739616 27 196 0 0 0 0 0 0 0 0 0 17020 69022 28971 31 4 65

    Reply
  2. Raj Prajapati says

    March 4, 2015 at 6:56 pm

    Why my calculation seems different, Please correct me.

    LRUE# /usr/sbin/prtconf | grep -i memory
    prtconf: devinfo facility not available
    Memory size: 10240 Megabytes #Memory size: 10 GB

    LRUE# sar -ru 5 5
    SunOS yosn66 5.10 Generic_144488-05 sun4v 03/04/2015
    12:47:53 freemem freeswap %usr %sys %wio %idle
    12:47:58 2980197 105450576 0 1 0 99
    12:48:03 2980199 105450576 0 1 0 99
    12:48:09 2980168 105450251 1 1 0 98
    12:48:14 2980160 105450186 1 1 0 98
    12:48:19 2980207 105450576 1 1 0 98

    Average 2980185 105450426
    Average 1 1 0 98
    LRUE#

    LRUE# pagesize
    8192

    Now when I calculating it then see what is output-

    Free memory in GB =2980185*8192/1024/1024/1024=22.73GB #how it is possible even I have only total 10 GB RAM
    Free swap in GB=105450426*512/1024/1024/1024=50.28GB

    Reply
  3. Mohame Amin says

    November 24, 2014 at 2:21 pm

    thank you very much
    But I wish to understand some things
    is this true or not ?
    RAM is the Memory
    Swap is a space on the H.D.D to add more memory for OS
    Virtual Memory = swap + RAM
    I have a server [ Solaris Domain] with 256 GB Mem and swap 48 GB
    # prtconf | grep Memory
    Memory size: 260864 Megabytes

    # swap -lh
    swapfile dev swaplo blocks free
    /dev/zvol/dsk/rpool/swap 287,2 8K 48G 48G

    Now when I write
    # swap -sh
    total: 61G allocated + 6.2G reserved = 67G used, 134G available

    I expected that [67G used + 134G available = 201 GB ] equal to [ Memory size 256 + swap -lh 48G = 304 GB]

    why this differance ??

    what exactly swap means ? the total of Mem plus partion on H.D.D or only partion on H.D.D

    thanks

    Reply
  4. STK says

    February 11, 2014 at 1:16 pm

    This clears up my doubts getting available free memory.
    Thanks for sharing.

    Reply
  5. Lingeswaran R says

    May 10, 2013 at 7:05 pm

    Thank you

    Reply
  6. Lingeswaran R says

    May 10, 2013 at 7:05 pm

    Thank you

    Reply
  7. Satya Hari says

    May 8, 2013 at 3:33 pm

    Nice one..thank you..

    Reply
  8. Shiva says

    April 24, 2013 at 7:43 am

    good one ..thank you ..

    Reply
  9. Lingeswaran R says

    April 19, 2013 at 1:12 am

    Block size=512

    Reply
  10. Nag says

    April 18, 2013 at 5:36 pm

    Hi Lingeswaran,

    I want to know the swap calculation
    Free swap in GB=89634194*512/1024/1024/1024=42.74GB

    What is 512 in the above calculation?

    Reply
  11. Lingeswaran R says

    April 13, 2013 at 12:46 am

    VMSTAT values will in KiloBytes. In order to convert those values in to GB = 44905096/1024/1024=42.82GB…

    Reply
  12. jayaprakasan says

    April 11, 2013 at 5:11 pm

    Free memory in GB=44905096/1024/1024=42.82GB

    what is 1024/1024

    I AM NOT CLEAR ON THAT

    Reply
    • Alhawari Alsaqri says

      March 7, 2022 at 9:58 am

      1024 kb =1 mb

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version