Unix script for finding unexported LUNs on 3PAR

Here is a script I threw together to quickly find all virtual volumes that are either exported to a hostgroup that has no active connections or find VVs that are not exported to any hostgroups.
This script also assumes you have your sshkeys setup in order to bypass typing in a password.

Also be aware this will grab ALL VVs, including any system VVs and file persona VV (see images below).

##Pass an array name to the command
##unexported.sh logs into the array and runs showvlun -a, showvuln -t, and showvv
##then it will compare the files and show the volumes that are exported but have no paths, and the volumes that are not exported
##ex: ./unexported <3parname or ip>
now=`date +"%m.%d.%Y.%H%M%S"`
arrayname=$1
showvluna=$arrayname.showvluna.$now
showvlunt=$arrayname.showvlunt.$now
showvv=$arrayname.showvv.$now
offline=$arrayname.offline.$now
unexported=$arrayname.unexported.$now
printf "\nSHOWVLUN -a\n"
ssh -T $arrayname "showvlun -a" | awk '{print $2}' | egrep -v 'VVName|total|VVname|^$' | sort -u | tee $arrayname.showvluna.$now
printf "\nSHOWVLUN -t\n"
ssh -T $arrayname "showvlun -t" | awk '{print $2}' | egrep -v 'VVName|total|VVname|^$' | sort -u | tee $arrayname.showvlunt.$now
printf "\nSHOWVV\n"
ssh -T $arrayname "showvv" | awk '{print $2}' | egrep -v 'VVName|total|VVname|Name|MB|virtual|^$' | tee $arrayname.showvv.$now
printf "\nLUN MAPPED, HOST OFFLINE\n"
grep -Fxvf $showvluna $showvlunt | tee $arrayname.offline.$now
printf "\nUNEXPORTED VOLUMES\n"
grep -Fxvf $showvlunt $showvv | tee $arrayname.unexported.$now
rm $showvlunt
rm $showvluna
rm $showvv

If you don’t want the script to give output after each login, change | tee to | >

 

Here is a redacted sample (note system vv “admin”):

An example containing file persona VVs:

Leave a Reply

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