1748169 Members
3677 Online
108758 Solutions
New Discussion юеВ

awk question

 
SOLVED
Go to solution
lawrenzo_1
Super Advisor

awk question

Hello,

I am attempting to write a report on SAN disk that is attached and how much space is available to the system in aix:

--> lsvg
rootvg
tsmlogvg
tsmdbvg
tsmdatavg
nimvg01
orabinvg1
oradatvg1
oraarcvg1


--> lsvg nimvg01
VOLUME GROUP: nimvg01 VG IDENTIFIER: 00c4816d00004c000000010d1114abf1
VG STATE: active PP SIZE: 32 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1725 (55200 megabytes)
MAX LVs: 256 FREE PPs: 348 (11136 megabytes)
LVs: 5 USED PPs: 1377 (44064 megabytes)
OPEN LVs: 5 QUORUM: 2
TOTAL PVs: 3 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 3 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable


--> lsvg -p nimvg01
nimvg01:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
vpath0 active 575 0 00..00..00..00..00
vpath1 active 575 189 66..00..00..57..66
vpath24 active 575 159 00..00..00..44..115


so from the commands above and the output I require I have created the following syntax:

--> for VOLUME in `lsvg`
> do
> PP=$(lsvg $VOLUME |awk '/PP SIZE:/ {print $6}')
> lsvg -p $VOLUME |awk -v VOL=$VOLUME -v PP=$PP 'NR>2 {OFS=",";print VOL,$1,$3*PP,$4*PP}'
> done


this output works well and I get the following:

rootvg,hdisk0,69888,46208
rootvg,hdisk1,69888,45312
nimvg01,vpath0,18400,0
nimvg01,vpath1,18400,6048
nimvg01,vpath24,18400,5088

what I would like to see is:

rootvg,hdisk0,69888,46208,hdisk1,69888,45312
nimvg01,vpath0,18400,0,vpath1,18400,6048,vpath24,18400,5088

any idea's how I can do this?

Thanks guys.

Chris.
hello
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: awk question

Hi Chris:

Given the final ouput as shown:

# awk -F"," '{if ($1==save) {line=line","$2","$3","$4;save=$1} else {if (ok++) {print line};save=$1;line=$0}};END{print line}'

Note (of course) that you can either pipe your previous stream into this or use the above and read a temporary file.

... | awk -F"." ...

(or):

awk -F"." ... file

Regards!

...JRF...
lawrenzo_1
Super Advisor

Re: awk question

Thanks James that works a treat.

Will add this to my ever building arsenal of awk commands.

much appreciated.

Chris.
hello