Operating System - HP-UX
1833187 Members
2830 Online
110051 Solutions
New Discussion

Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

 
SOLVED
Go to solution
Alzhy
Honored Contributor

Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

I am planning to write an LVM utility that does among others:
.
- list what VG's are there in a system
- list LVOLS within a VG with formatting
- show member PV's within a VG
- Free extents on a VG
- Free extents within a PV
- etc., etc. sort of equivs on commands avail on VxVM.
.
Has anyone doen this already? Instead of reinventing the wheel.. would anyone be kind enough to share their script(s).
.
Graci!
Hakuna Matata.
13 REPLIES 13
Cheryl Griffin
Honored Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

Steven E. Protter
Exalted Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

I have some pieces. The nicest piece I have is disk.status

It checks disks and can be used to display more information if you wish to play with it.

Attaching.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Cheryl Griffin
Honored Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

Camel_1
Valued Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

see attached, check all PV status (size, free space), and the assoicate VGs & LVs.
Hein van den Heuvel
Honored Contributor
Solution

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet



I cobbled up the attached little perl script to summarize VG / LV / PV data from vgdisplay. I'll include it here, but you problably should use the attached version as the forum still swallows spaces.

Enjoy,
Hein.

#!/usr/contrib/bin/perl -w
print "Type Name Allocated Total Free\n";
print "---- --------------------------- -------- -------- --------\n";
foreach $_ (`/usr/sbin/vgdisplay -v`) {
if (/^(\s*\w\w) Name\s+(\S+)/) {
$type = $1;
$name = $2;
$name =~ s/\/dev//;
}
$pe = $1 if (/^PE Size \(Mbytes\)\s+(\w+)/);
$alloc = $1 if (/Allo.* PE\s+(\w+)/);
$total = $1 if (/Total PE\s+(\w+)/);
$free = $1 if (/Free PE\s+(\w+)/);
if (/^$/) {
printf ("%-6s%-30s%9d%9d%9d\n",
$type, $name, $pe * $alloc, $pe * $total, $pe * $free);
$name = $type = " ";
$alloc = $total = $free = 0;
}
}

Alzhy
Honored Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

Hein,
.
Exactly what I am looking for!
.
Thanks a whole lot!
Hakuna Matata.
Geoff Wild
Honored Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

Hein,

I get the following using your script:

printf (...) interpreted as function at /usr/local/bin/vgdisplay.pl line 15.


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Todd McDaniel_1
Honored Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

I have a simple one that lists disks by VG, can be modified to list by LV as well.

# cat vglist.sh
for name in `cat /root/vgnames.out `
do
echo $name
vgdisplay -v $name |grep "PV Name" |awk '{ print $3 }'
done > /root/disks.by.VG.`date +%m%d%y` 2> /root/vgerr.`
date +%m%d%y`
Unix, the other white meat.
Hein van den Heuvel
Honored Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet


Thanks for the feedback. I posted an early version with " -w " warnings requested.
Here is a more recent one, with STRIPES added, and lines with zeroes replaced by blanks.

#!/usr/contrib/bin/perl

print "Type Name Stripes Allocated Total Free\n";
print "---- ------------------------------ -- -------- -------- --------\n";
foreach $_ (`/usr/sbin/vgdisplay -v`) {
if (/^(\s*\w\w) Name\s+(\S+)/) {
$type = $1;
$name = $2;
$name =~ s/\/dev//;
}
$pe = $1 if (/^PE Size \(Mbytes\)\s+(\w+)/);
$alloc = $1 if (/Allo.* PE\s+(\w+)/);
$total = $1 if (/Total PE\s+(\w+)/);
$free = $1 if (/Free PE\s+(\w+)/);
$s = $1 if (/Used PV\s+(\w+)/);
if (/^$/) {
if ($alloc + $total + $free) {
printf ("%-6s%-30s%3s%9d%9d%9d\n",
$type, $name, ($s)?$s :" ", $pe * $alloc, $pe * $total, $pe * $free);
} else { print "\n" } ;
$name = $type = " ";
$alloc = $total = $free = $s = 0;
}
}




Geoff Wild
Honored Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

This one summarizes just the VG's - called vgttl - uses bdfmegs.

Output:

# vgttl
VG Size(MB) In use Available
vg00 22780 5700 16546
vg01 12288 4 11901
vg30iqa 1311456 1186182 124296
vg31iqa 2048 1028 956
vg32iqa 232688 22685 206161
----- -------------- -------------- --------------
Total 1581260 1215599 359860



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Geoff Wild
Honored Contributor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

Oh....and here is bdfmegs....

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Dave van Nierop
Advisor

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

Yes - check out Ralph Roth's (HP engineer) "cfg2html" utility. This does LVM and just about everything else you will need to document a HP server (and is available for other platforms as well).

http://come.to/cfg2html

- Dave

Re: Has Anyone Written a "Suite" of LVM Tools/Scripts Yet

excuse me guy i think that you can use HATOOLS which have a lot of good script like xvg
The beaver