Hereby i post the new version of the HBA auto lunbalancing script version 2.1
It doesn't matter if you have 2 4 6 or 8 storage paths to your LUNs this will balance it automaticly for you to spread the load.
for PATHS in 2 4 6 8 do STPATHS=${PATHS} COUNTER="1" for LUN in $(esxcfg-mpath -l | grep "has ${STPATHS} paths" | awk '{print $2}') do esxcfg-mpath --lun=${LUN} --path=$(esxcfg-mpath -q --lun=${LUN} | grep FC | awk '{print $4}' | awk '{print NR "S\t " $0}' | grep ${COUNTER}S | awk '{print $2}') --preferred COUNT=`expr ${COUNTER} + 1` COUNTER=${COUNT} if [[ ${COUNTER} -gt ${STPATHS} ]] then COUNTER="1" fi done done
Happy MPIO
This looks interesting. It just so happens I will be able to test it in my development environment in the next week or so. I will let you know how it works.
To give you and idea, your esxcfg-mpath -l will look like this after you used the script.
Disk vmhba2:1:4 /dev/sdh (512000MB) has 4 paths and policy of Fixed FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:4 On active preferred FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:4 On FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:4 On FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:4 On Disk vmhba2:1:5 /dev/sdi (512000MB) has 4 paths and policy of Fixed FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:5 On FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:5 On active preferred FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:5 On FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:5 On Disk vmhba2:1:6 /dev/sdj (307200MB) has 4 paths and policy of Fixed FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:6 On FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:6 On FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:6 On active preferred FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:6 On Disk vmhba2:1:7 /dev/sdk (307200MB) has 4 paths and policy of Fixed FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:7 On FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:7 On FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:7 On FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:7 On active preferred Disk vmhba2:1:8 /dev/sdl (512000MB) has 4 paths and policy of Fixed FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:8 On active preferred FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:8 On FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:8 On FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:8 On Disk vmhba2:1:9 /dev/sdm (512000MB) has 4 paths and policy of Fixed FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:9 On FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:9 On active preferred FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:9 On FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:9 On
Awesome!
Hello
Sorry for the stupid question, but i know very little about scripts in ESX (and scripts in general!) but i would like to achive what your script does!
Firstly, is this a shell script? As i'm getting the following
'ath.sh: line 2: syntax error near unexpected token `do
'ath.sh: line 2: `do
Secondly, if not. what is it and how do i run it?
I'm not a complete moron, honestly!
Thanks in advance
TH
Resolved - copy paste format issue.