Open vieyahn2017 opened 7 months ago
#!/bin/bash
tmpfile=/root/multipath_tmp
[ -e "$tmpfile" ] && rm -rf $tmpfile
function explain_one_foreach () {
for lun in $(cat "$WWIDS" | grep -v ^# | sed s#/##g);
do
result=$(multipath -ll "$lun" 2> /dev/null)
echo "$result" | grep " sd" | awk -v nlun="$lun" '{print nlun" "$3" "$2" "$5" "$6" "$7}' >> $tmpfile
done
}
function explain_all () {
results=$(multipath -ll 2> /dev/null)
lun=""
echo "$results" | while read line;
do
if [ "${line:0:2}" == "36" ]; then
lun=$(echo $line | awk '{print $1}')
fi
if [ $(echo $line | grep -c " sd") -eq 1 ]; then
echo "$line" | awk -v nlun="$lun" '{print nlun" "$3" "$2" "$5" "$6" "$7}'
fi
done
}
WWIDS=/etc/multipath/wwids
if [ ! -f /etc/multipath/wwids ]; then
echo "/etc/multipath/wwids files not existed"
if [ $(multipath -ll 2>&1 | grep -c "DM multipath kernel driver not loaded") -eq 1 ]; then
echo "DM multipath kernel driver not loaded"
exit 1
fi
fi
explain_all >> $tmpfile
exit 0