Operating System - HP-UX
1755751 Members
3784 Online
108837 Solutions
New Discussion юеВ

Script to identify alternate PV links

 
SOLVED
Go to solution
unixnewbie
Advisor

Script to identify alternate PV links

I would like to know whether any of the HP-UX gurus here has got a script/one liner to identify alternate PV links easily ? If so could you please share it ?

Thanks in advance.
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor

Re: Script to identify alternate PV links

Hi:

Using:

# vgdisplay -v

...will show alternate links under the "Physical volumes" stanza.

Regards!

...JRF...
unixnewbie
Advisor

Re: Script to identify alternate PV links

Hi JRF,

Thanks for that.. But I need some thing more than that.. I am in the process of documenting the hardware configuration/usage of a number of servers. As a part of it I need the number of disks and the alternate PV links to each disks on a given server.So I am looking for a script/one liner which I can execute and collect the data with out looking in to the VG configuration.
Steven E. Protter
Exalted Contributor
Solution

Re: Script to identify alternate PV links

Shalom,

I have a few EMC centric scripts that might help.

Some modification is required.

bdf | awk -F\/ '{print $3}' | sort -u | while read -r dv
do
echo "VG:${dv}"
vgdisplay -v $dv | grep "PV Name" | grep -v "Alternate Link"| awk -F\/ '{print
$4}' | while read -r dn
do
diskdev=$(grep $dn /tmp/inq.txt | awk -F\/ '{print $4}');
emcdev=$(grep $dn /tmp/inq.txt | awk -F: '{print $5}');
emcsize=$(grep $dn /tmp/inq.txt | awk -F: '{print $6}');
done
echo "Device: ${diskdev} EMCdev: ${emcdev} EMCSIZE: ${emcsize}"
done


#!/bin/ksh

ITF="interim.disk.list.data"

cp diskrep.txt ${ITF}

bdf | awk '{print $1}' | awk -F\/ '{print $3}' | sort -u | grep -v "^$" | while read -r vg
do
echo ${vg}
vgdisplay -v $vg | awk '/PV Name/' | grep -v "Alternate Link" | awk '{print $3}' | while read -r dn
do
echo "disk: ${dn}"
p1="dev"
p3=$(echo $dn | awk -F\/ '{print $4}')
p2="rdsk"
dinfostring="/${p1}/${p2}/${p3}"
dsize=$(diskinfo ${dinfostring}| grep "size:" | awk '{print $2}')
symid=$(grep ${dinfostring} /tmp/inq.txt | awk -F: '{print $5}')
echo "source: ${dinfostring} size: $dsize (kb) symid: $symid"
# get the destination disk by size create interim file
# 1 get sim id and device of a disk of the same size from the file
# echo "About to grep dsize: ${dsize}"
DL=$(grep ${dsize} ${ITF} | head -1)
# echo "data line is: ${DL}"
if [ "$DL" = "" ]
then
print No Match Found for disk ${dn}
continue
fi
dsimid=$(echo $DL | awk '{ print $5}')
dsdisk=$(echo $DL | awk '{ print $1}')
echo "dest: ${dsdisk} id: ${dsimid}"
grep -v $dsimid ${ITF} > tfile
cp tfile ${ITF}
done
done


This last one is really good and can actually extend your volume group to include alternate links.

None of these scripts are good enough for my blog yet, and they are sadly going to need modification to work with systems that do not have the EMC inq utility.

#!/bin/ksh
inq > /tmp/inq.out
LF="log.txt"
vgname=$1
# vgdisplay -v $vgname | awk -F/ '!/Alternate/ && /PV Name/ {print }'
vgdisplay -v $vgname | awk -F/ '!/Alternate/ && /PV Name/ {print $4}' | while read dname
do
# awk -F: '/\/dev\/rdsk\/'$dname'/ {print }'
sid=$(awk -F: '/\/dev\/rdsk\/'$dname'/ {print $5}' /tmp/inq.out )
echo "sid is ${sid} dname is ${dname}"
# for newdsk in $(awk -F: '{if($5 == "'${sid}'") {print $1} }' /tmp/inq.out | sed 's/rdsk/dsk/g')
# awk -v dsid=${sid} -F: '/'$sid'/ {print}' /tmp/inq.out
# grep ${sid} /tmp/inq.out | awk -F: '{print "vgextend vg08 ",$1}' | sed 's/rdsk/dsk/g'
VGI="/tmp/${vgname}.dat"
vgdisplay -v ${vgname} | awk '/PV Name/ {print $3}' > ${VGI}
for newdsk in $(grep ${sid} /tmp/inq.out |awk '{print $1}' | sed 's/rdsk/dsk/g')
do
# see if disk is present before running vgexend.
present=$(grep ${newdsk} ${VGI} | wc -l)
print vgextend ${vgname} ${newdsk} present: $present
if [ $present -eq 1 ]
then
echo "Disk $newdsk present in $vgname doing nothing"
else
echo "Disk $newdsk NOT present in $vgname extending volume group"
vgreduce -l $vgname $newdsk
vgextend $vgname $newdsk
fi
# echo $newdisk >> $LF
done
done
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
unixnewbie
Advisor

Re: Script to identify alternate PV links

Hi Steven,

Thank you very much for the scripts. I am yet to try these. I do have servers with inq utility installed on them. I believe this will save a lot of time for me. Thanks again

Note: I am not closing this thread now..Anybody who have better suggestions please post :)
rariasn
Honored Contributor

Re: Script to identify alternate PV links

Hi,

If you have "symcli" (emc):

# symvg list -v|more

Volume Group Name : /dev/vgxxxxx
Volume Group Type : HP-UX LVM

Volume Group State : Enabled

Volume Group Attributes : Multipathed devices

Group's Physical Extent Size : 4096k

Max Number of Devices in Group : 32
Max Number of Volumes in Group : 255

Number of Devices in Group : 4
Number of Volumes in Group : 26

Physical Device Members (4):
{
-------------------------------------------------------
Cap
PdevName Array Dev Att. Sts (MB)
-------------------------------------------------------
/dev/rdsk/c34t1d2 02627 06E5 (S) RW 8632
/dev/rdsk/c34t1d3 02627 06E6 (S) RW 8632
/dev/rdsk/c34t1d4 02627 06E7 (S) RW 8632
/dev/rdsk/c34t1d5 02627 06E8 (S) RW 8632
}

rgs,
Raj D.
Honored Contributor

Re: Script to identify alternate PV links

unixnewbie, #vgdisplay -v|grep -e "VG Name" -e dsk #Cheers.
" If u think u can , If u think u cannot , - You are always Right . "