scripts/fiber_channel/get-vdev-wwn-sn

23 lines
754 B
Plaintext
Raw Permalink Normal View History

#!/bin/bash
touch /tmp/vdev-wwn-sn.list;
echo "" > /tmp/vdev-wwn-sn.list;
# eg: /dev/disk/by-id/dm-uuid-mpath-32208000a338f2d50
for device in $(find /dev/disk/by-id -name 'dm-uuid-mpath-32208000a338*')
do
#wwn=$(echo "${device}" | cut -d"/" -f5 | cut -d"-"cut -f4);
wwn=$(/lib/udev/scsi_id -g -u -d "${device}");
# eg : 32208000a338f2d50a338f2d50
slot=$(multipath -l "${device}" | egrep "^ \`- [0-9]*\:[0-9]*\:[0-9]*\:[0-9]* " | cut -d":" -f3);
# eg : 18
sn=$(smartctl -dm scsi -i "${device}" | /bin/egrep "^Serial number:" | /bin/sed 's/^Serial number\: *//');
echo "alias disk${slot} dm-uuid-mpath-${wwn}" >> /tmp/vdev-wwn-sn.list;
done
sort -g /tmp/vdev-wwn-sn.list > /tmp/vdev-wwn-sn-sorted.list;
cat "/tmp/vdev-wwn-sn-sorted.list";