; html-script: false crayon-selected ]#!/bin/bash
KEY_FILE="/root/.ssh/netapp.dsa"
SSH_OPTS="/root/.ssh/netapp-ssh_config"
FAS_CTRL=$1
ssh_fas() {
# $@: commands for Data ONTAP
COMMANDS="$@"
/usr/bin/ssh -i $KEY_FILE -l root -F $SSH_OPTS $COMMANDS
}
for volume in $( ssh_fas $FAS_CTRL vol status | grep "vol.* online" | awk '{ print $1 }' ); do
VOL_SIZE="$( ssh_fas $FAS_CTRL vol size $volume | awk '{ print $8 }' | sed "s,.,," )"
VOL_UNIT_PARAM="$( echo "${#VOL_SIZE} - 1" | bc )"
VOL_UNIT="${VOL_SIZE:$VOL_UNIT_PARAM:1}"
case $VOL_UNIT in
k) CONV="1024";;
m) CONV="1024 * 1024";;
g) CONV="1024 * 1024 * 1024";;
esac
VOL_SIZE="$( echo "scale=0; ${VOL_SIZE/$VOL_UNIT/} * $CONV" | bc )"
# Subtract the snap reserve (if any)
SNAP="$( ssh_fas $FAS_CTRL snap reserve $volume | cut -d -f7 | sed "s,%,," )"
if [ $SNAP -gt 0 ] ; then
SNAP_SIZE="$( echo "$VOL_SIZE * $SNAP / 100" | bc )"
REMAINING_VOL_SIZE="$( echo "$VOL_SIZE - $SNAP_SIZE" | bc )"
else
SNAP_SIZE=0
REMAINING_VOL_SIZE=$VOL_SIZE
fi
# Get the luns created inside the volume
LUN_SIZE_TOTAL=0
for lunsize in $( ssh_fas $FAS_CTRL lun show -l ${volume} | awk '{ print $3 }' | sed -e "s,(,," -e "s,),," ); do
LUN_SIZE_TOTAL="$( echo "$LUN_SIZE_TOTAL + $lunsize" | bc )"
REMAINING_VOL_SIZE="$( echo "$REMAINING_VOL_SIZE - $lunsize" | bc )"
done
# Get the estimated space necessary.
VOL_RESERVE="$( echo "$VOL_SIZE * 3 / 100" | bc )"
echo " VOL_NAME: $volume"
echo " VOLUME_SIZE: $( echo "scale=2; $VOL_SIZE / 1024 / 1024 / 1024" | bc )G"
echo " - SNAP_SIZE: $( echo "scale=2; $SNAP_SIZE / 1024 / 1024 / 1024" | bc )G"
echo " SUB_TOTAL: $( echo "scale=2; ($VOL_SIZE - $SNAP_SIZE) / 1024 / 1024 / 1024" | bc )G"
echo
echo " - TOTAL_LUN_SIZE: $( echo "scale=2; $LUN_SIZE_TOTAL / 1024 / 1024 / 1024" | bc )G"
echo " SUB_TOTAL: $( echo "scale=2; ($VOL_SIZE - $SNAP_SIZE - $LUN_SIZE_TOTAL) / 1024 / 1024 / 1024" | bc )G"
echo
echo " MISSING_SPACE:"
DIFFERENCE_VOL_LUN="$( echo "scale=2; ($VOL_SIZE - $SNAP_SIZE - $LUN_SIZE_TOTAL)" | bc | sed "s,-,," )"
echo " DIFFERENCE_VOL_LUN: $( echo "scale=2; $DIFFERENCE_VOL_LUN / 1024 / 1024 / 1024" | bc )G"
echo " + VOL_RESERVE: $( echo "scale=2; $VOL_RESERVE / 1024 / 1024 / 1024" | bc )G"
echo " SUB_TOTAL: $( echo "scale=2; ($DIFFERENCE_VOL_LUN + $VOL_RESERVE) / 1024 / 1024 / 1024" | bc )G"
echo
echo
echo
done