AIX script to list 3Par hdisks/LUN #/Volume Group
Posted: Thu Dec 10, 2009 11:06 am
We wanted an easy way to list the 3Par luns on AIX and see what they were assigned to, specifically which volume group or if they were raw disks in Oracle ASM. We provision multiple tiers of storage to database hosts. FC 15k disks are used for the database drives, and SATA is used for the flash recovery area (backup to disk). Communication between storage admin and AIX admin can get confusing when trying to identify which luns are the SATA for backups.
Our local AIX team wrote these scripts to make this task easier. Root not required. You should have your AIX admin evaluate these scripts before you install and run them on their systems.
The first script is a modified lspv that lists all physical disks and displays which VG they are assigned to or if they belong to Oracle ASM.
lspv2
The second script depends on the first script, and builds a list of just 3par disks, LUN ID, and VG assignment.
ls3par
Our local AIX team wrote these scripts to make this task easier. Root not required. You should have your AIX admin evaluate these scripts before you install and run them on their systems.
The first script is a modified lspv that lists all physical disks and displays which VG they are assigned to or if they belong to Oracle ASM.
lspv2
Code: Select all
#!/bin/ksh
if [ $# -eq 0 ]
then
touch /tmp/ASM_lspv.out
/usr/sbin/lspv > /tmp/lspv.out
for i in `grep None /tmp/lspv.out | awk '{print $1}'`
do
ls -l /dev/r${i} | grep oracle > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$i" >> /tmp/ASM_lspv.out
fi
done
cat /tmp/lspv.out | grep -vwf /tmp/ASM_lspv.out > /tmp/lspv1.out 2>/dev/
null
cat /tmp/lspv.out | grep -wf /tmp/ASM_lspv.out | sed 's/none
None/ASM Disk For Oracle ASM Disk act
ive/' > /tmp/lspv2.out 2>/dev/null
cat /tmp/lspv1.out /tmp/lspv2.out
rm -f /tmp/ASM_lspv.out
rm -f /tmp/lspv.out
rm -f /tmp/lspv1.out
rm -f /tmp/lspv2.out
else
/usr/sbin/lspv $*
fi
The second script depends on the first script, and builds a list of just 3par disks, LUN ID, and VG assignment.
ls3par
Code: Select all
echo "Disk\tLUN\tVG Name"
for i in `lsdev -Cc disk | grep -i 3par | awk '{print $1}'`
do
LUNID=`lsattr -El $i | grep -i lun | awk '{print $2}' | awk -F"x" '{print $2}' |
awk -F"000000000000$" '{print $1}'`
((mydec=16#$LUNID))
VGNM=`/opt/local/bin/lspv2 | grep -w $i | awk '{print $3}' | sed 's/Disk/ASM Dis
k/g'`
echo "$i\t$mydec\t$VGNM" >> /tmp/3par.$$
done
cat /tmp/3par.$$ | sort -n +1 2>/dev/null
rm -f /tmp/3par.$$
Example Output wrote:Disk LUN VG Name
hdisk23 0 backupsvg
hdisk24 1 backupsvg
hdisk25 2 backupsvg
hdisk26 3 backupsvg
hdisk27 4 backupsvg
hdisk28 5 backupsvg
hdisk29 6 ASM Disk
hdisk30 7 ASM Disk
hdisk31 8 ASM Disk
hdisk32 9 ASM Disk
hdisk33 10 ASM Disk
hdisk42 11 hrdvora1vg
hdisk43 12 hrdvora3vg
hdisk44 13 hrdvora2vg
hdisk45 14 hrdvp1vg