Monday 17 October 2016

Script for identifying multiple disks on a Linux server

This is a short script for identifying 3 PAR disks allocated to a physical server running Linux with multipathing enabled.

Put the disk WWN details provided by the SAN admin in a file called detail.txt.

Now run the following for loop to extract the mpath devices corresponding to the disk WWNs.

#!/bin/bash

for i in `cat detail.txt | awk '{print $3}' |  egrep -v 'showvlun|VV_WWN' | uniq -u`

do

echo "corresponding to 

 `cat detail.txt | awk '{print $3}' |  egrep -v 'showvlun|VV_WWN' | uniq -u | grep -i $i` disk is 
  `multipath -ll | grep -i -A1 $i |awk '{print $1}'` "
  
done

The output of the script is as follows:

corresponding to

 60002AC00000000000004BD20000935D disk is
  mpathv
size=500G
corresponding to

 60002AC00000000000004BD30000935D disk is
  mpatht
size=500G
corresponding to

 60002AC00000000000004BD40000935D disk is
  mpaths
size=500G
corresponding to

 60002AC00000000000004BD50000935D disk is
  mpathu
size=500G
corresponding to

 60002AC00000000000004BD60000935D disk is
  mpathw
size=500G

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...