Home > Storage > PowerStore > Data Protection > Dell PowerStore: Metro Volume > map-paths.sh script
This sample script is provided as-is and requires minor modification to match your PowerStore appliances.
Update the target_arrays section in the script with your PowerStore appliance port WWPN and WWNN, and assign a descriptive label for each port.
#!/bin/bash
# Initialize variables to store the option values
long_format=false
search_string=""
extra_info=""
# Use getopts to process the command-line options
# -l display additional fields
# -s multipath device pattern
while getopts ":ls:" opt; do
case $opt in
l) long_format=true ;;
s) search_string=$OPTARG ;;
\?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;;
:) echo "Option -$OPTARG requires an argument." >&2; exit 1 ;;
esac
done
declare -A target_arrays=(
["0x58ccf0904a600faa"]="array2-na-iom0-p0"
["0x58ccf0904a610faa"]="array2-na-iom0-p1"
["0x58ccf0984a600faa"]="array2-nb-iom0-p0"
["0x58ccf0984a610faa"]="array2-nb-iom0-p1"
["0x58ccf0904a600feb"]="array1-na-iom0-p0"
["0x58ccf0904a610feb"]="array1-na-iom0-p1"
["0x58ccf0984a600feb"]="array1-nb-iom0-p0"
["0x58ccf0984a610feb"]="array1-nb-iom0-p1"
["iqn.2015-10.com.dell:dellemc-powerstore-fnm72141021010-a-499c2a02"]="array2-na-bond0"
["iqn.2015-10.com.dell:dellemc-powerstore-fnm72141021010-b-771ac1b0"]="array2-nb-bond0"
["iqn.2015-10.com.dell:dellemc-powerstore-fnm72141021011-a-200105b5"]="array1-na-bond0"
["iqn.2015-10.com.dell:dellemc-powerstore-fnm72141021011-b-79d782c0"]="array1-nb-bond0"
)
while read multipath_name device status prio host_wwpn target_wwpn protocol iscsi_iqn lun_wwn
do
# Includes only relevant information for the protocol
case "$protocol" in
"scsi:fcp")
array_port_wwn="$host_wwpn $target_wwpn"
target_array=${target_arrays[$target_wwpn]:-"Unknown array"} ;;
"scsi:iscsi")
array_port_wwn="$iscsi_iqn"
target_array=${target_arrays[$iscsi_iqn]:-"Unknown array"} ;;
"scsi:unspec") break ;;
esac
# Query the target port group and the ALUA state of the path
tpgid=$(sg_inq -p 0x83 /dev/$device |awk '/Target port group: / {print $NF}')
aluastate=$(sg_rtpg -d /dev/$device |grep -EiA1 "target port group id.*$tpgid" |awk -F"(" '/asymmetric access state/ {print $NF}' | tr -d '()' )
if [[ "$long_format" == "true" ]];then
extra_info="$protocol $array_port_wwn $lun_wwn"
fi
# Format color highlights for AO and Unavailable ALUA status.
if [[ "$aluastate" =~ "active/optimized" ]]; then
echo "$multipath_name $(tput setaf 2)$device $status $prio $aluastate $extra_info $target_array$(tput sgr0)"
elif [[ "$aluastate" =~ "unavailable" ]];then
echo "$multipath_name $(tput setaf 1)$device $status $prio $aluastate $extra_info $target_array$(tput sgr0)"
else
echo "$multipath_name $device $status $prio $aluastate $extra_info $target_array"
fi
done < <(multipathd show paths format "%m %d %t %p %R %r %P %n %w" | grep -Eiv "uuid|orphan") | grep -Ei "$search_string" | sort -k1,1 -k4,4nr -k2,2