Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting LV size

Status
Not open for further replies.

gatetec

MIS
Mar 22, 2007
420
US
I have this working ksh, and it returns like below:

LOGICAL VOLUME: prod_2048_005 VOLUME GROUP: prod1vg
TYPE: raw WRITE VERIFY: off
PHYSICAL VOLUME: hdisk108 VOLUME GROUP: prod1vg
TOTAL PPs: 1023 (130944 megabytes) VG DESCRIPTORS: 1
USED PPs: 904 (115712 megabytes) MAX REQUEST: 1 megabyte USED DISTRIBUTION: 192..205..204..204..99
FREE PPs: 119 (15232 megabytes) HOT SPARE: no FREE DISTRIBUTION: 13..00..00..00..106

I like to have a horizontal format with additional PP Size info with the header names like below:

i.e.
LV TYPE PV TOTAL USED FREE PP
prod_2048_005 raw hdisk101 1023 904 119 32

for i in `cat temp.txt`
do
for n in `lslv -l $i|cut -d" " -f1|egrep -v "PV|:"`
do
echo `lslv $i|egrep "LOGICAL VOLUME"`
echo `lslv $i|egrep "TYPE"`
echo `lspv $n|egrep "PHYSICAL VOLUME"`
echo `lspv $n|egrep "TOTAL"`
echo `lspv $n|egrep "USED"`
echo `lspv $n|egrep "FREE"`
echo
done
done


Please advise.

thx mucg
 
Try this:

Code:
temp=""
for i in `cat temp.txt`
do
        for n in `lslv -l $i|cut -d" " -f1|egrep -v "PV|:"`
        do
                temp=$(echo `lslv $i|egrep "LOGICAL VOLUME"` | awk '{ printf $3 }')
                temp=$temp"\t"$(echo `lslv $i|egrep "TYPE"` | awk '{ printf $2 }')
                temp=$temp"\t"$(echo `lspv $n|egrep "PHYSICAL VOLUME"` | awk '{ printf $3 }')
                temp=$temp"\t"$(echo `lspv $n|egrep "TOTAL"` | awk '{ printf $3 }')
                temp=$temp"\t"$(echo `lspv $n|egrep "USED"` | awk '{ printf $3 }')
                temp=$temp"\t"$(echo `lspv $n|egrep "FREE"` | awk '{ printf $3 }')
                echo "LV\tTYPE\tPV\tTOTAL\tUSED\tFREE\tPP"
                echo $temp
        done
done

I haven't checked the code so i dont' expect it to run error-free from the first time!

Regards,
Khalid
 
If you intend to use the same lsvg, lspv or lslv command repeatedly in scripts, it is better to run it once and store the output in a variable, then use the contents of that variable repeatedly. You'll get a much faster script run time:

Code:
echo "LV\tTYPE\tPV\tTOTAL\tUSED\tFREE\tPP"
for i in $(cat temp.txt)
do
        temp=""
        lslv_i_out=$(lslv $i)
        for n in `lslv -l $i|cut -d" " -f1|egrep -v "PV|:"`
        do
                lspv_n_out=$(lspv $n)
                temp=$(echo "${lslv_i_out}"|egrep "LOGICAL VOLUME" | awk '{ printf $3 }')
                temp=$temp"\t"$(echo "${lslv_i_out}"|egrep "TYPE" | awk '{ printf $2 }')
                temp=$temp"\t"$(echo "${lspv_n_out}"|egrep "PHYSICAL VOLUME" | awk '{ printf $3 }')
                temp=$temp"\t"$(echo "${lspv_n_out}"|egrep "TOTAL" | awk '{ printf $3 }')
                temp=$temp"\t"$(echo "${lspv_n_out}"|egrep "USED" | awk '{ printf $3 }')
                temp=$temp"\t"$(echo "${lspv_n_out}"|egrep "FREE" | awk '{ printf $3 }')
                echo $temp
        done
done

again, just like Khalidaaa has warned, this is not tested...


HTH,

p5wizard
 
I'm sorry that I found an issue with my question.
What I want is the free size of LV, NOT the free size of PV.
It is RAW LV. How do you get the free size of RAW LV?

lslv and lsatte -El don't show the free size of RLV.

thx much
 
I don't think it is possible to know that free size of a raw logical volume without going through the application/database that is accessing it.

What do others think?
 
Yes Spamly, you are right!

Code:
A raw logical volume is an area of physical and logical disk space that is under the direct control of an application, such as a database or a partition, rather than [b]under the direct control of the operating system or a file system[/b].


Regards,
Khalid
 
thx so much.
I figured the OS can't determine the size of RAW.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top