Need to get customized o/p (162 Views)
Reply
Valued Contributor
Sreer
Posts: 222
Registered: ‎07-02-2008
Message 1 of 3 (162 Views)

Need to get customized o/p

Hello Gurus,

 

Iam trying to generate a customized o/p from my server. say example I need to print the o/p as below  from vgdisplay command.

 

VG Status    Max LV  Total PE
available      255        8680

 

[In vertical ways as column wise] Ineed it urgently since i need to collect it from nearly 100+ servers,,,,,,


--- Volume groups ---
VG Name                     /dev/vg00
VG Write Access             read/write
VG Status                   available
Max LV                      255
Cur LV                      9
Open LV                     9
Max PV                      16
Cur PV                      2
Act PV                      2
Max PE per PV               4350
VGDA                        4
PE Size (Mbytes)            8
Total PE                    8680
Alloc PE                    8672
Free PE                     8
Total PVG                   0
Total Spare PVs             0
Total Spare PVs in use      0


VG Status  Max LV  Total PE
available  255      8680

 

Could you please help me?

 

Rgds

Sree

Please use plain text.
Honored Contributor
Patrick Wallek
Posts: 13,752
Registered: ‎06-21-2000
Message 2 of 3 (154 Views)

Re: Need to get customized o/p

Try this short script.  Substitute the appropriate VG name in place of VG00 below.

 

# cat testfile
#!/usr/bin/sh
echo " VG Status       Max LV  Total PE"
vgdisplay vg00 |grep -e "Status" -e "Max LV" -e "Total PE" | awk '{ printf ("%10s", $3) }'
echo ""
echo ""

# sh ./testfile
 VG Status       Max LV  Total PE
 available       255     69996

 

Please use plain text.
Honored Contributor
Patrick Wallek
Posts: 13,752
Registered: ‎06-21-2000
Message 3 of 3 (153 Views)

Re: Need to get customized o/p

Here's a modification that will pick up all VGs on a system.

 

# cat testfile
#!/usr/bin/sh
VGNAME=$(vgdisplay | grep "VG Name" | awk '{print $3}')
for VG in $VGNAME
do
  echo "VG Name: ${VG}"
  echo " VG Status       Max LV  Total PE"
  vgdisplay ${VG} |grep -e "Status" -e "Max LV" -e "Total PE" | awk '{ printf ("%10s", $3) }'
  echo ""
  echo ""
done


# ./testfile
VG Name: /dev/vg00
 VG Status       Max LV  Total PE
 available       255     69996

VG Name: /dev/vgbig
 VG Status       Max LV  Total PE
 available       255     61236

VG Name: /dev/vgpcbackup
 VG Status       Max LV  Total PE
 available       255     30618

 

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation