VOLUME GROUP: rootvg VG IDENTIFIER: 00c701f000004c0000000117d056caf8
VG STATE: active PP SIZE: 64 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 2186 (139904 megabytes)
MAX LVs: 256 FREE PPs: 288 (18432 megabytes)
LVs: 16 USED PPs: 1898 (121472 megabytes)
OPEN LVs: 12 QUORUM: 1 (Disabled)
TOTAL PVs: 2 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 2 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 2032 MAX PVs: 16
LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
lsvg $i | awk -v VG="$i" '
# Execute this code for lines matching TOTAL PP
/TOTAL PP/ { TPP=$6 }
# Execute this code for lines matching FREE PP
/FREE PP/ { FPP=$6 }
# You know the drill by now
/PP SIZE/ { S=$6 }
# Execute this code after all lines are read
END {
TPP=(TPP*S)/1024;
FPP=(FPP*S)/1024;
printf("VG Name: %s Total VG Size: %.1f Free VG Size: %.1f\n", VG, TPP, FPP);
}'
Using lsvg $(lsvg) eliminates the need to use (yuk) for i in `lsvg` , or a while loop. And there's a "cost" benefit in lsvg $(lsvg) than the iteration alternatives for those who think every CPU cycle is a prisoner(!), as lsvg is only executed twice regardless of how many volume groups there are.
So, the code I posted will give output for all volume groups.
lsvg | while read VG; do
lsvg $VG ...
...
done
for example, will execute lsvg #of VG's + 1 times.