Home / Solaris 10 / Solaris Memory swap Usage script with Percentage

Solaris Memory swap Usage script with Percentage

How do you to find total physical memory & total swap space in Solaris ? How do you  find free physical memory &  free swap space on the system ?   

For all the questions, here  the answer is one small simple script. Off course you can use various system commands to find each values with lot of effect.And also you can use  top utility but there is no guarantee that “top” will give right values.But you can always trust Solaris commands like vmstat & sar values.So i have decided to make the script using bash shell and Solaris in-built commands. 

Total physical memory may show till lower than actual installed memory.But this script will show total usable physical memory.(echo ‘::memstat’ | mdb -k)
Commands used in this script:
1. echo ‘::memstat’ | mdb -k  –  To find physical memory 
2.swap -l  –  To find total swap space
3.vmstat 1 2 – To find current free memory & free swap
You can download Memory statistics script here.

Sample output of the script:

Total Physical Memory = 251 GB
Total Swap Space = 295 GB
Total Virtual storage space(Physical + Swap) = 546 GB
Free Physical Memory = 87.48 GB
Free Swap = 273.95 GB
Free Virtual storage space(Free Physical + Free Swap) = 361 GB
Free Virtual storage Percentage = 66.11 %
System is running with enough virtual storage space(Free virtual storage space 66.11 %)


Verifying the script output with other system commands:

# vmstat 1 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
 0 0 0 336864920 125991448 1363 4799 823 68 67 0 2 23 21 21 0 13576 97161 16001 10 3 87
 0 0 0 287271208 91721144 365 4181 0 0 0 0 0 0 0  0  0 13604 59918 19709 8 4 88
 0 0 0 287271864 91721328 967 4212 0 8 8 0 0 2 2  2  0 13183 56024 18985 8 4 88
 0 0 0 287268216 91721320 383 4104 60 0 0 0 0 0 0 0  0 10641 40352 13485 8 3 89


Verifying using top output:

# /usr/local/bin/top
last pid: 23154;  load averages:  7.63,  9.27,  9.92      16:30:04
1467 processes:1460 sleeping, 2 zombie, 5 on cpu
CPU states: 90.3% idle,  5.4% user,  4.3% kernel,  0.0% iowait,  0.0% swap
Memory: 256G real, 87G free, 230G swap in use, 273G swap free

Hope this script have saved your time to find memory statistics on Solaris servers.
I have tested this script in Solaris 10 SPARC & X86 servers.

You can download Memory statistics script here.

To see the local zone wise memory usage,use zonestat script.

Thank you for reading this article.Please leave a comment if you have any doubt.

VMTURBO-CLOUD-CAPACITY

One comment

  1. last pid: 7491; load avg: 1.20, 1.14, 1.12; up 834+13:29:32 05:35:25
    154 processes: 146 sleeping, 3 zombie, 3 stopped, 2 on cpu
    CPU states: 96.3% idle, 3.4% user, 0.3% kernel, 0.0% iowait, 0.0% swap
    Memory: 8184M phys mem, 1045M free mem, 2052M total swap, 1808M free swap

    So in this case,total swap space is 2052mb out of which 1808mb is free…it it correct??

Leave a Reply

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