In the case, where you'd have system monitoring in place and you need to find out how much swap space has been utilized. The way of calculating the percentage of swap space utilized on a Solaris system is:
% swap utilized
= (swap used / swap total) %
The swap total should be:
swap total = swap used + swap available
And when you subsitute the value from swap -s
# swap -s
total: 10527072k bytes allocated + 1647056k reserved = 12174128k used, 3572696k available
actual swap total
= 12174128k + 3572696k
= 15746824k
% swap utilized
= (12174128k/15746824k) * 100
= 77.31 % (rounded to the nearest two decimals points)
You can conveniently script this using bourne or bourne again shell.
swapinfo=`swap -s`
swapused=`echo $swapinfo | awk '{print $9}' | sed 's/k//'`
swapavail=`echo $swapinfo | awk '{print $11}' | sed 's/k//'`
swaptotal=`echo $swapused+$swapavail | bc`
swapusedpercent=`echo "scale=5; ($swapused/$swaptotal)*100" | bc -l`
echo "Swap utilization is at $swapusedpercent %"
No comments:
Post a Comment