Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

Need to get customized o/p

Valued Contributor

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

2 REPLIES
Honored Contributor Honored Contributor

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

 

Honored Contributor Honored Contributor

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