dispaly vg's and pv's?


 
Thread Tools Search this Thread
Operating Systems AIX dispaly vg's and pv's?
# 1  
Old 09-05-2008
CPU & Memory dispaly vg's and pv's?

hi

i need to write a script,

the script display's list of volume groups followed by physical volumes with in volume group and at the same time the script should display the pvid of physical volume.

what i need is, how to read the line by line from the files...

the below is my script..

echo "List of Volume Groups and Physical Volume:"
while read xxxxxx (the xxxx should read from file reportvg.out)
do
lsvg -p xxxxxx > reportpv.out (the xxxxx is vg anme)
while read xxxxxx ( the xxxx is the pv name from reportpv.out)
do
lspv xxxxx | grep IDENTIFIER ( the xxxx is pv name)
done reportpv.out
done reportvg.out


can anyone help me on this.



thanks

Last edited by honeym210; 09-05-2008 at 11:59 AM..
# 2  
Old 09-05-2008
In one shot (not considering you want separate report files) I might do something like this:

for MyVG in `lsvg`
do
echo "\n\n Volume Group: $MyVG\n------------------"
for MyPV in `lsvg -p $MyVG|grep -v -e $MyVG -e PV_NAME|awk '{ print $1 }'`
do
MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
echo $MyPV $MyID
done
done
# 3  
Old 09-05-2008
i got it..

my script is ....

#!/bin/ksh
#Removing Old Files.
rm output
rm reportvg.out
rm reportpv.out
rm errors
#List of Volume Groups.
lsvg >> reportvg.out
#Creating file for output.
touch output
touch errors
echo "List of Volume Groups and Physical Volume:" >> output
while read -r line
do
echo "Volume Group Name: " $line >> output
lsvg -p $line > reportpv.out
while read -r line
do
#echo "Physical Volume Name: " $line >> output
lspv $line | grep 'PHYSICAL VOLUME' | awk '{print $1 " " $2 "\t" $3}' >> output
lspv $line | grep 'PV IDENTIFIER' | awk '{print $1 " " $2 "\t" "\t" $3}' >> output
done < reportpv.out
echo " " >> output
done < reportvg.out


it works beautiful...
thanks
# 4  
Old 09-06-2008
Just a minor observation:

Quote:
Originally Posted by Rob Kerrr
MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
Don't let era, our local "herder of useless cats", see that ;-)) :

.... awk '{ /PV IDENTIFIER/ print $3 }'....

would do the same as "....grep ...| awk ....", yes?

I have long given up on pointing out that backticks are considered harmful in the Korn shell and "`...`" should be replaced by "$(....)".

And for the audience: please use [ code ]...[ /code ]-tags when posting code. The difference is:

with code-tags:
Code:
for MyVG in `lsvg`
do
     echo "\n\n Volume Group: $MyVG\n------------------"
     for MyPV in `lsvg -p $MyVG|grep -v -e $MyVG -e PV_NAME|awk '{ print $1 }'`
     do
          MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
          echo $MyPV $MyID
     done
done

and the same without:
for MyVG in `lsvg`
do
echo "\n\n Volume Group: $MyVG\n------------------"
for MyPV in `lsvg -p $MyVG|grep -v -e $MyVG -e PV_NAME|awk '{ print $1 }'`
do
MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
echo $MyPV $MyID
done
done

bakunin

Last edited by bakunin; 09-06-2008 at 05:47 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Solaris

Dispaly IP address

How to display the IP address in authlog and sulog? (1 Reply)
Discussion started by: Burhan
1 Replies

2. UNIX for Advanced & Expert Users

Issue with dispaly of special character like 'TM'

Hi, I've an xml file with special characetr 'TM' (trade mark sign). The issue is that I am not able to get the symbol 'TM'(trade mark sign) on unix. It displays '?' instead. I've searched the solution on net. Wht I've found is that the symbol 'TM' does not come under ISO-8859-1 char set. So I... (0 Replies)
Discussion started by: vbehal
0 Replies
Login or Register to Ask a Question