diff --git a/lx-lvm/lvs.pl b/lx-lvm/lvs.pl index 86ce7ae..04944e5 100644 --- a/lx-lvm/lvs.pl +++ b/lx-lvm/lvs.pl @@ -72,14 +72,14 @@ unless ($options{'size'}) { }; # print header -printf STDOUT ("\n%-30s %-12s %-17s %-6s %-10s %-7s %-8s %-8s\n", +printf STDOUT ("\n%-30s %-12s %-17s %-7s %-17s %-7s %-8s %-8s\n", "LV", "VG", "Status", "Size", "Permissions", "Mirrors", "Stripes", "Allocation"); # fetch LVOLs if ($options{'vg'}) { - @vgdisplay = `/usr/sbin/vgdisplay -vF ${options{'vg'}} | grep "^lv_name"`; + @vgdisplay = `/usr/sbin/vgdisplay -vF ${options{'vg'}} 2>/dev/null | grep "^lv_name"`; } else { - @vgdisplay = `/usr/sbin/vgdisplay -vF | grep "^lv_name"`; + @vgdisplay = `/usr/sbin/vgdisplay -vF 2>/dev/null | grep "^lv_name"`; } die "failed to execute: $!" if ($?); @@ -88,7 +88,7 @@ foreach my $lvol (@vgdisplay) { my $lv_name = (split (/=/, (split (/:/, $lvol))[0]))[1]; - @lvdisplay = `/usr/sbin/lvdisplay -F ${lv_name}`; + @lvdisplay = `/usr/sbin/lvdisplay -F ${lv_name} 2>/dev/null`; die "failed to execute: $!" if ($?); # loop over lvdisplay @@ -113,7 +113,7 @@ foreach my $lvol (@vgdisplay) { # convert to GB if needed $lv_size /= 1024 unless ($options{'size'} =~ /MB/i); # report data - printf STDOUT ("%-30s %-12s %-17s %-7d %-17s %-7s %-2s %-5s\n", + printf STDOUT ("%-30s %-12s %-17s %-7d %-17s %-7s %-8s %-8s\n", ${lv_name}, ${vg_name}, ${lv_status}, @@ -177,4 +177,5 @@ S< >Show logical volume size in MB or GB (default is GB). =head1 history -@(#) 2016-04-12: VRF 1.0.0: first version [Patrick Van der Veken] \ No newline at end of file +@(#) 2016-04-12: VRF 1.0.0: first version [Patrick Van der Veken] +@(#) 2016-04-27: VRF 1.0.1: small fixes [Patrick Van der Veken] \ No newline at end of file diff --git a/lx-lvm/pvs.pl b/lx-lvm/pvs.pl index 270bdfe..537636a 100644 --- a/lx-lvm/pvs.pl +++ b/lx-lvm/pvs.pl @@ -77,9 +77,9 @@ printf STDOUT ("\n%-20s %-10s %-15s %-7s %-8s %-8s %-8s\n", # fetch LVOLs if ($options{'vg'}) { - @vgdisplay = `/usr/sbin/vgdisplay -vF ${options{'vg'}} | grep "^pv_name"`; + @vgdisplay = `/usr/sbin/vgdisplay -vF ${options{'vg'}} 2>/dev/null | grep "^pv_name"`; } else { - @vgdisplay = `/usr/sbin/vgdisplay -vF | grep "^pv_name"`; + @vgdisplay = `/usr/sbin/vgdisplay -vF 2>/dev/null | grep "^pv_name"`; } die "failed to execute: $!" if ($?); @@ -88,7 +88,7 @@ foreach my $pvol (@vgdisplay) { my $pv_name = (split (/=/, (split (/:/, $pvol))[0]))[1]; - @pvdisplay = `/usr/sbin/pvdisplay -F ${pv_name}`; + @pvdisplay = `/usr/sbin/pvdisplay -F ${pv_name} 2>/dev/null`; die "failed to execute: $!" if ($?); # loop over pvdisplay @@ -181,4 +181,5 @@ S< >Show physical volume size in MB or GB (default is GB). =head1 history -@(#) 2016-04-12: VRF 1.0.0: first version [Patrick Van der Veken] \ No newline at end of file +@(#) 2016-04-12: VRF 1.0.0: first version [Patrick Van der Veken] +@(#) 2016-04-27: VRF 1.0.1: small fixes [Patrick Van der Veken] \ No newline at end of file diff --git a/lx-lvm/vgs.pl b/lx-lvm/vgs.pl index 0cbf798..9e29c67 100644 --- a/lx-lvm/vgs.pl +++ b/lx-lvm/vgs.pl @@ -31,6 +31,7 @@ use warnings; use POSIX qw(uname); use Getopt::Long; use Pod::Usage; +use Data::Dumper; $|++; @@ -72,14 +73,14 @@ unless ($options{'size'}) { }; # print header -printf STDOUT ("\n%-10s %-5s %-5s %-20s %-8s %-8s %-10s %-10s %-10s\n", - "VG", "PVs", "LVs", "Status", "Version", "PE Size", "VG Size", "VG Free", "VG Max"); +printf STDOUT ("\n%-15s %-5s %-5s %-20s %-8s %-8s %-10s %-10s %-10s %-12s\n", + "VG", "PVs", "LVs", "Status", "Version", "PE Size", "VG Size", "VG Free", "VG Max", "VG Major/Minor"); # fetch vgdisplay if ($options{'vg'}) { - @vgdisplay = `/usr/sbin/vgdisplay -F ${options{'vg'}}`; + @vgdisplay = `/usr/sbin/vgdisplay -F ${options{'vg'}} 2>/dev/null`; } else { - @vgdisplay = `/usr/sbin/vgdisplay -F`; + @vgdisplay = `/usr/sbin/vgdisplay -F 2>/dev/null`; } die "failed to execute: $!" if ($?); @@ -87,7 +88,7 @@ die "failed to execute: $!" if ($?); # loop over vgdisplay foreach my $vg_entry (@vgdisplay) { - my ($vg_name, $vg_status, $vg_version)= ("","","n/a"); + my ($vg_name, $vg_status, $vg_version, $lsvg, $vg_major, $vg_minor,) = ("","","n/a","","n/a","n/a"); my ($vg_total_pe, $vg_size_pe, $vg_free_pe, $vg_cur_pvs, $vg_cur_lvs, $vg_max_pe) = (0,0,0,0,0,0); my ($vg_size, $vg_free, $vg_max) = (0,0,0); @@ -106,7 +107,7 @@ foreach my $vg_entry (@vgdisplay) { $vg_cur_pvs = $1 if ($vg_field =~ m%^cur_pv=(.*)%); $vg_cur_lvs = $1 if ($vg_field =~ m%^cur_lv=(.*)%); $vg_version = $1 if ($vg_field =~ m%^vg_version=(.*)%); - $vg_max_pe = $1 if ($vg_field =~ m%^vg_max_extents=(.*)%); + $vg_max_pe = $1 if ($vg_field =~ m%^vg_max_extents=(.*)%); } } # calculate sizes @@ -118,9 +119,15 @@ foreach my $vg_entry (@vgdisplay) { $vg_max = $vg_max_pe * $vg_size_pe; $vg_max /= 1024 unless ($options{'size'} =~ /MB/i); } + # get minor number + $lsvg = `/usr/bin/ls -l /dev/${vg_name}/group 2>/dev/null`; + unless ($?) { + $vg_major = (split (/\s+/, $lsvg))[4]; + $vg_minor = (split (/\s+/, $lsvg))[5]; + } # report data - printf STDOUT ("%-10s %-5s %-5s %-20s %-8s %-8d %-10d %-10d %-10d\n", + printf STDOUT ("%-15s %-5s %-5s %-20s %-8s %-8d %-10d %-10d %-10d %3s/%-8s\n", ${vg_name}, ${vg_cur_pvs}, ${vg_cur_lvs}, @@ -129,7 +136,9 @@ foreach my $vg_entry (@vgdisplay) { ${vg_size_pe}, ${vg_size}, ${vg_free}, - ${vg_max}) + ${vg_max}, + ${vg_major}, + ${vg_minor}) } # footer @@ -185,4 +194,5 @@ S< >Show volume group sizes in MB or GB (default is GB). =head1 history -@(#) 2016-04-12: VRF 1.0.0: first version [Patrick Van der Veken] \ No newline at end of file +@(#) 2016-04-12: VRF 1.0.0: first version [Patrick Van der Veken] +@(#) 2016-04-27: VRF 1.0.1: added 'VG Major/Minor' [Patrick Van der Veken] \ No newline at end of file