Improve 3ware support
authorJamie Cameron <jcameron@webmin.com>
Thu, 30 Sep 2010 04:07:18 +0000 (21:07 -0700)
committerJamie Cameron <jcameron@webmin.com>
Thu, 30 Sep 2010 04:07:18 +0000 (21:07 -0700)
smart-status/CHANGELOG
smart-status/smart-status-lib.pl

index 4355aaf..209d131 100644 (file)
@@ -17,3 +17,5 @@ Added support for FreeBSD and OSX systems, if they have the smartctl package ins
 Fixed the collapsible section showing raw SMART status output.
 ---- Changes since 1.500 ----
 Use disk IDs for SMART monitoring instead of device names, which may change.
+---- Changes since 1.520 ----
+Fix support for 3ware hardware RAID arrays with non-contiguous disks.
index 922c461..e962f2e 100755 (executable)
@@ -57,12 +57,14 @@ foreach my $d (&fdisk::list_disks_partitions()) {
                # underlying real disks, so add fake devices for them
                foreach my $twdev (keys %tcount) {
                        next if (!-r $twdev.$tcount{$twdev});
-                       my $count = &count_3ware_subdisks($d, $tcount{$twdev})
-                                   ||
-                                   &count_subdisks($d, "3ware",
+                       my @subdisks = &list_3ware_subdisks($d,$tcount{$twdev});
+                       if (!@subdisks) {
+                               my $count = &count_subdisks($d, "3ware",
                                                    $twdev.$tcount{$twdev});
-                       next if (!$count);
-                       for(my $i=0; $i<$count; $i++) {
+                               next if (!$count);
+                               @subdisks = ( 0 .. $count-1 );
+                               }
+                       foreach my $i (@subdisks) {
                                push(@rv, { 'device' => $twdev.$tcount{$twdev},
                                            'prefix' => $twdev.$tcount{$twdev},
                                            'desc' => '3ware physical disk '.$i,
@@ -98,24 +100,23 @@ return sort { $a->{'device'} cmp $b->{'device'} ||
              $a->{'subdisk'} <=> $b->{'subdisk'} } @rv;
 }
 
-=head2 count_3ware_subdisks(&drive, number)
+=head2 list_3ware_subdisks(&drive, number)
 
-Returns the number of underlying hard drives in a 3ware device, or undef
-if we can't work this out.
+Returns a list of numbers of 3ware sub-disk
 
 =cut
-sub count_3ware_subdisks
+sub list_3ware_subdisks
 {
 local ($d, $n) = @_;
 local $out = &backquote_command("tw_cli info c$n");
-return undef if ($?);
-local $max_disk;
+return () if ($?);
+my @rv;
 foreach my $l (split(/\r?\n/, $out)) {
-       if ($l =~ /^p(\d+)\s+/ && $1 >= $max_disk) {
-               $max_disk = $1;
+       if ($l =~ /^p(\d+)\s+/) {
+               push(@rv, $1);
                }
        }
-return $max_disk;
+return @rv;
 }
 
 =head2 count_subdisks(&drive, type, [device])