summaryrefslogtreecommitdiff
path: root/pvinfo
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2010-03-22 22:45:22 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2010-03-22 22:45:22 +0000
commit5f15d40181a9a49f6c0583431be0f2ee2d913bbd (patch)
treec175ff650475204fcc3ce31478ce88f066df8c50 /pvinfo
parentf67e3bc2e45ed0cd759a2c00cc45fa4c7c0c4b3a (diff)
Update pvinfo
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@449 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'pvinfo')
-rwxr-xr-xpvinfo115
1 files changed, 85 insertions, 30 deletions
diff --git a/pvinfo b/pvinfo
index 5b13c69..b2380ac 100755
--- a/pvinfo
+++ b/pvinfo
@@ -2,7 +2,8 @@
# show the distribution of LVs/LEs in the systems PVs
#
-# Copyright 2005, 2008 Uli Martens <uli@youam.net>
+# Copyright 2005, 2008, 2009 Uli Martens <uli@youam.net>
+# 2009 Peter Palfrader <peter@palfrader.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -18,6 +19,10 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# ChangeLog:
+# 2009-05-30 Peter Palfrader <peter@palfrader.org>
+# * teach it about striped logical volumes
+# 2009-01-05 Uli Martens <uli@youam.net>
+# * right-justify #PE, fixes ragged output for large slices
# 2008-01-20 Uli Martens <uli@youam.net>
# * fix off-by-two error for lv slice sizes
# 2005-04-11 Uli Martens <uli@youam.net>
@@ -90,7 +95,7 @@ VG: while (<LVD>) {
my $pfrom;
my $pto;
my $pv;
- while (<LVD>) {
+ LE: while (<LVD>) {
if ( m/^ --- Logical volume ---/ ) {
next VG;
}
@@ -99,32 +104,82 @@ VG: while (<LVD>) {
$to = $2;
next;
}
- if ( m/^ Physical volume\s+(.*)$/ ) {
- $pv = $1;
- next;
- }
- if ( m/^ Physical extents\s+(\d+) to (\d+)$/ ) {
- $pfrom = $1;
- $pto = $2;
- next;
- }
-
- if ( m/^\s*$/ and defined $pv ) {
- #print "GOT: $pv / $from / $to\n";
- $all->{$vg}->{$pv}->{lvs}->{$pfrom} = {
- from => $pfrom,
- to => $pto,
- lv => $lv,
- pv => $pv,
- pfrom => $from,
- pto => $to,
- };
- undef $pv;
- undef $from;
- undef $to;
+ if ( m/^ Type\s+linear$/ ) {
+ while (<LVD>) {
+ if ( m/^ Physical volume\s+(.*)$/ ) {
+ $pv = $1;
+ next;
+ }
+ if ( m/^ Physical extents\s+(\d+) to (\d+)$/ ) {
+ $pfrom = $1;
+ $pto = $2;
+ next;
+ }
+
+ if ( m/^\s*$/ and defined $pv ) {
+ #print "GOT: $pv / $from / $to\n";
+ $all->{$vg}->{$pv}->{lvs}->{$pfrom} = {
+ from => $pfrom,
+ to => $pto,
+ lv => $lv,
+ pv => $pv,
+ pfrom => $from,
+ pto => $to,
+ };
+ undef $pv;
+ undef $from;
+ undef $to;
+ next LE;
+ }
+ #print ">> $_";
+ }
+ } elsif ( m/^ Type\s+striped$/ ) {
+ my $numstripes;
+ my $curstripe;
+ while (<LVD>) {
+ if ( m/^ Stripes\s+(.*)$/ ) {
+ $numstripes = $1;
+ next;
+ }
+ while (<LVD>) {
+ if ( m/^ Physical volume\s+(.*)$/ ) {
+ $pv = $1;
+ next;
+ }
+ if ( m/^ Physical extents\s+(\d+) to (\d+)$/ ) {
+ $pfrom = $1;
+ $pto = $2;
+ next;
+ }
+ if ((m/^\s*$/ or m/ Stripe\s+(\d+):/) and defined $pv ) {
+ #print "GOT: $pv / $from / $to\n";
+ $all->{$vg}->{$pv}->{lvs}->{$pfrom} = {
+ from => $pfrom,
+ to => $pto,
+ lv => $lv." ($curstripe/$numstripes)",
+ pv => $pv,
+ pfrom => $from,
+ pto => $to,
+ };
+ undef $pv;
+ undef $pfrom;
+ undef $pto;
+ }
+ if (m/ Stripe\s+(\d+):/) {
+ $curstripe = $1;
+ }
+ if ( m/^\s*$/) {
+ undef $pv;
+ undef $from;
+ undef $to;
+ next LE;
+ }
+ }
+ }
+ } elsif ( m/^ Type\s+(.*)$/ ) {
+ warn "Do not understand type $1 for $lv"."'s extend $from - $to.\n";
+ next LE;
}
-
- #print ">> $_";
}
}
#print "XX $_";
@@ -141,12 +196,12 @@ for my $vg ( sort keys %{$all} ) {
my $pelast = -1;
for my $x ( sort { $a <=> $b } keys %{$all->{$vg}->{$pv}->{lvs}} ) {
if ( $pelast + 1 != $all->{$vg}->{$pv}->{lvs}->{$x}->{from} ) {
- printf " (%7i ..%7i (%5i ))\n",
+ printf " (%7i ..%7i (%6i))\n",
$pelast+1,
$all->{$vg}->{$pv}->{lvs}->{$x}->{from} -1,
$all->{$vg}->{$pv}->{lvs}->{$x}->{from} - $pelast -1;
}
- printf " (%7i ..%7i (%5i )) -- %*s (%7i ..%7i )\n",
+ printf " (%7i ..%7i (%6i)) -- %*s (%7i ..%7i )\n",
$all->{$vg}->{$pv}->{lvs}->{$x}->{from},
$all->{$vg}->{$pv}->{lvs}->{$x}->{to},
$all->{$vg}->{$pv}->{lvs}->{$x}->{to} - $all->{$vg}->{$pv}->{lvs}->{$x}->{from} +1,
@@ -157,7 +212,7 @@ for my $vg ( sort keys %{$all} ) {
$pelast = $all->{$vg}->{$pv}->{lvs}->{$x}->{to};
}
if ( $pelast != $all->{$vg}->{$pv}->{size} ) {
- printf " (%7i ..%7i (%5i ))\n",
+ printf " (%7i ..%7i (%6i))\n",
$pelast +1,
$all->{$vg}->{$pv}->{size},
$all->{$vg}->{$pv}->{size} - $pelast;