- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: scripting help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2007 05:11 PM
тАО08-08-2007 05:11 PM
I am trying to write a script that will give me the Free PE and PE Sizeon all VG's except /dev/vg00 on close to 100 servers
i have the ouput of #vgdisplay -v from all the servers copied up
how can i grep/ sed or awk only the VG Name, PE Size and Free PE lines?
eg
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 14
Open LV 14
Max PV 16
Cur PV 2
Act PV 2
Max PE per PV 4384
VGDA 4
PE Size (Mbytes) 16
Total PE 4340
Alloc PE 4340
Free PE 0
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0
VG Name /dev/vgora
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 1
Open LV 1
Max PV 16
Cur PV 2
Act PV 2
Max PE per PV 2489
VGDA 4
PE Size (Mbytes) 4
Total PE 4978
Alloc PE 3250
Free PE 1728
Total PVG 0
Total Spare PVs 0
I would like the output to look like
VG Name /dev/vgora
PE Size (Mbytes) 4
Free PE 1728
exlcude /dev/vg00 and get the 3 paremeters for other vgs.
thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2007 05:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2007 05:42 PM
тАО08-08-2007 05:42 PM
Re: scripting help
ssh hostname ls -1d /dev/vg* | grep -v vg00 | xargs vgdisplay 2>&- | egrep '(^VG N|^PE|^Free)'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2007 06:06 PM
тАО08-08-2007 06:06 PM
Re: scripting help
Actually i am doing this on a file. Here is the output. how can i exclude the 3 lines for /dev/vg00?
cat VGDISPLAY | egrep '(^VG N|^PE|^Free)'
VG Name /dev/vg00
PE Size (Mbytes) 16
Free PE 0
VG Name /dev/vgora
PE Size (Mbytes) 4
Free PE 1728
VG Name /dev/vgkctr8
PE Size (Mbytes) 4
Free PE 685
VG Name /dev/vgkctr9
PE Size (Mbytes) 4
Free PE 685
VG Name /dev/vgkdprd
PE Size (Mbytes) 4
Free PE 3446
VG Name /dev/vgkct10
PE Size (Mbytes) 4
Free PE 685
VG Name /dev/vgptprd
PE Size (Mbytes) 4
Free PE 3446
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2007 07:11 PM
тАО08-08-2007 07:11 PM
Re: scripting help
cat filename|xargs -n10|grep -v vg00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2007 12:25 AM
тАО08-09-2007 12:25 AM
Re: scripting help
Actually i am doing this on a file. Here is the output. how can i exclude the 3 lines for /dev/vg00?
Either:
# vgdisplay -v|awk '/^VG Name|^PE|^Free/ {if (i++<3) {next};print}'
...or:
# awk '/^VG Name|^PE|^Free/ {if (i++<3) {next};print}' VGDISPLAY
...where (of course) "VGDISPLAY" in all uppercase letters is the name of your file.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2007 12:48 AM
тАО08-09-2007 12:48 AM
Re: scripting help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2007 02:22 AM
тАО08-09-2007 02:22 AM
Re: scripting help
and I get the following outpupt:
+++< /dev/vg01 >+++
/dev/vg01 PE size 4 Total allocated : 83.977 GB Available : 0.188 GB
LV Name Mir Size Stripe Stripe size Mount Point
/dev/vg01/lvol1 0 1000.000 MB 0 0 /usr/A
/dev/vg01/lvol10 0 200.000 MB 0 0 /oracle/A/A
/dev/vg01/lvol11 0 200.000 MB 0 0 /oracle/A/B
/dev/vg01/lvol12 0 2000.000 MB 0 0 /oracle/A/org
/dev/vg01/lvol13 0 16500.000 MB 0 0 /oracle/A/data1
/dev/vg01/lvol14 0 12000.000 MB 0 0 /oracle/A/data2
/dev/vg01/lvol15 0 12000.000 MB 0 0 /oracle/A/data3
/dev/vg01/lvol16 0 13500.000 MB 0 0 /oracle/A/data4
/dev/vg01/lvol2 0 5000.000 MB 0 0 /mnt/A
/dev/vg01/lvol3 0 5000.000 MB 0 0 /usr/a/A
/dev/vg01/lvol4 0 5000.000 MB 0 0 /oracle
/dev/vg01/lvol5 0 5000.000 MB 0 0 /oracle/age
/dev/vg01/lvol6 0 2000.000 MB 0 0 /oracle/A
/dev/vg01/lvol7 0 6000.000 MB 0 0 /oracle/A/64
/dev/vg01/lvol8 0 2000000 MB 0 0 /oracle/A/logA
/dev/vg01/lvol9 0 200.000 MB 0 0 /oracle/A/logB
As you see this report shows Lvol, Mirror if there is, # stripes, stripe size and mount point.
If you need to modify just to show the vg with out the lvol info use the following
#!/usr/bin/ksh
# 06/14/07 JML
if [ `uname -s` != "HP-UX" ] ; then
echo " This script was build to run on HPUX systems... Thank you ! "
exit 99
fi
# List of VG
for VG in `ls -d /dev/vg* | grep -v vg00`
do
echo "+++< ${VG} >+++"
vgdisplay $VG > /dev/null 2>&1
if [ $? -ne 0 ] ; then
echo " Volume group \"$VG\" does not exist in the "/etc/lvmtab" file, or is not active. "
else
vgdisplay $VG | awk '/VG Name/ {printf "%-17s ",$NF}
/PE Size \(Mbytes\)/ {PESZ=$NF;printf "PE size %-4s ",$NF}
/Total PE/ {printf "Total allocated :%8.3f GB ",((PESZ*$NF)/1024)}
/Free PE/ {printf "Available :%8.3f GB \n\n",((PESZ*$NF)/1024)}'
fi
done
Let me know if you need help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2007 02:25 AM
тАО08-09-2007 02:25 AM
Re: scripting help
#!/usr/bin/ksh
# 06/14/07 JML
if [ `uname -s` != "HP-UX" ] ; then
echo " This script was build to run on HPUX systems... Thank you ! "
exit 99
fi
# List of VG
for VG in `ls -d /dev/vg* | grep -v vg00`
do
echo "+++< ${VG} >+++"
vgdisplay $VG > /dev/null 2>&1
if [ $? -ne 0 ] ; then
echo " Volume group \"$VG\" does not exist in the "/etc/lvmtab" file, or is not active. "
else
vgdisplay $VG | awk '/VG Name/ {printf "%-17s ",$NF}
/PE Size \(Mbytes\)/ {PESZ=$NF;printf "PE size %-4s ",$NF}
/Total PE/ {printf "Total allocated :%8.3f GB ",((PESZ*$NF)/1024)}
/Free PE/ {printf "Available :%8.3f GB \n\n",((PESZ*$NF)/1024)}'
# List of lvol
printf " %-17s %-4s %10s %6s %10s %20s \n" "LV Name" "Mir" "Size" "Stripe" "Stripe size" "Mount Point"
for LVOL in `ls ${VG}/lvo*`
do
mount -p | egrep -e "$LVOL " > /dev/null
if [ $? -ne 0 ] ; then
MOUNTPOINT="not_found"
else
MOUNTPOINT=`mount -p | egrep "$LVOL " | awk '{print $2}'`
fi
lvdisplay ${LVOL} | awk '/LV Name/ {printf "%-17s ",$NF}
/Mirror copies/ {printf "%-5s ",$NF}
/LV Size \(Mbytes\)/ {printf "%10.3f MB ",$NF}
/Stripes/ {printf "%6s ",$NF}
/Stripe Size / {printf " %10s ",$NF}'
printf " %-20s \n" $MOUNTPOINT
done
printf " \n"
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2007 03:14 AM
тАО08-09-2007 03:14 AM
Re: scripting help
Once you have those Name, Size and Free lines, don't you want to report them more nicely?
Please consider a slightly more elaborate script, for example along the lines of the perl example below, to really parse the input data and add some more value.
$ perl x.pl x.txt
Name Size Free Mbytes
---- ---- ---- ------
/dev/vgora 4 1728 6912
------------------ x.pl -------------------
#!/usr/bin/perl
use strict;
use warnings;
my ($name, $size, $free);
my $format = "%20s %4s %6s %6s\n";
printf $format, qw(Name Size Free Mbytes);
printf $format, qw(---- ---- ---- ------);
while (<>) {
$name = $1 if /^VG Name\s+(.*)$/;
$size = $1 if /^PE S.*\s(\d+)/;
if (/^Free PE\s+(\d+)$/) {
$free = $1;
printf ("%20s %4d %6d %6d\n", $name, $size, $free, $free*$size) unless $name =~ /vg00/
}
}
---------------------------
Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting