About a year ago I wrote about a script that would load balance your Active/Active SAN by evenly dividing LUNs on all available paths. A week ago I provided Kees van Vloten with this script so that it could be incorporated into a scripted install solution. Kees has enhanced the script and emailed it so that I could share it with you guys:
for N_PATHS in 2 4 6 8; do
# These are the LUNs with N_PATHS:
LUN_LIST=`esxcfg-mpath -l | egrep "^Disk.+has $N_PATHS paths" | awk '{print $2}'`
N=1
for LUN in $LUN_LIST; do
echo "LUN: $LUN, Counter: $N, Possible paths:"
esxcfg-mpath -q --lun=$LUN | grep "FC" | awk '{print $4}'
# Take the Nth path for this LUN
LUN_NEWPATH=`esxcfg-mpath -q --lun=$LUN | \
grep "FC" | awk '{print $4}' | head -n $N | tail -n 1`
# Make the Nth path the preferred path
esxcfg-mpath --lun=$LUN --path=$LUN_NEWPATH --preferred
echo ""
# Increase N (within the limit)
N=$(($N+1))
if [ $N -gt $N_PATHS ]; then
N=1
fi
done
done
Thanks for sharing,