Thursday, February 23, 2017

Memory Script I/O Domain Solaris

The following script is useful to see the memory information on an I/O Domain on Solaris. I have used this script on an M7 Supercluster deployment on Solaris 11. You can see the total available memory, free memory and the used memory.

#!/usr/bin/ksh

# Available memory
memory=`prtconf | grep Memory | head -1 | awk 'BEGIN {FS=" "} {print $3}'`
gb_memory=`echo "scale=2; $memory/1024" | bc -l`

# Free memory
pagesize=`pagesize`
kb_pagesize=`echo "scale=2; $pagesize/1024" | bc -l`
sar_freemem=`sar -r 1 1 | tail -1 | awk 'BEGIN {FS=" "} {print $2}'`
gb_freemem=`echo "scale=2; $kb_pagesize*$sar_freemem/1024/1024" | bc -l`

# Used Memory
gb_usedmem=`echo "scale=2; $gb_memory-$gb_freemem" | bc -l`

# Conclusion
echo "Avai Mem: $gb_memory GB"
echo "Free Mem: $gb_freemem GB"
echo "Used Mem: $gb_usedmem GB"


Sample Output below:
--------------------------


$ free.sh
Avai Mem: 96.00 GB
Free Mem: 42.02 GB
Used Mem: 53.98 GB






No comments:

Post a Comment