Handle old and new 3ware
authorJamie Cameron <jcameron@webmin.com>
Sat, 28 Mar 2009 06:00:17 +0000 (06:00 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sat, 28 Mar 2009 06:00:17 +0000 (06:00 +0000)
smart-status/CHANGELOG
smart-status/smart-status-lib.pl

index 4f2655f..962c0a0 100644 (file)
@@ -10,3 +10,5 @@ ATA mode is now used by default on CentOS and Redhat Enterprise versions 5 and a
 SCSI drives are visible in the System and Server Status module.
 The SMART status monitor now has an option to only alert if the error count on a drive has increased.
 Improved support for 3ware and HP RAID devices, so that the underlying disks are now detected and can be reported on separately.
+---- Changes since 1.470 ----
+Added support for systems with both old and new 3ware cards.
index 54508cf..419280c 100644 (file)
@@ -34,26 +34,28 @@ May include faked-up 3ware devices
 sub list_smart_disks_partitions
 {
 local @rv;
-local $threecount = 0;
+local %tcount = ( "/dev/twe", 0, "/dev/twa", 0 );
 foreach my $d (&fdisk::list_disks_partitions()) {
        if (($d->{'type'} eq 'scsi' || $d->{'type'} eq 'raid') &&
            $d->{'model'} =~ /3ware/i) {
                # Actually a 3ware RAID device .. but we want to probe the
                # underlying real disks, so add fake devices for them
-               my $twdev = -r "/dev/twe0" ? "/dev/twe" :
-                           -r "/dev/twa0" ? "/dev/twa" : "/dev/twe";
-               my $count = &count_subdisks($d, "3ware",
-                                           $twdev.$threecount);
-               for(my $i=0; $i<$count; $i++) {
-                       push(@rv, { 'device' => $twdev.$threecount,
-                                   'prefix' => $twdev.$threecount,
-                                   'desc' => '3ware physical disk '.$i,
-                                   'type' => 'scsi',
-                                   'subtype' => '3ware',
-                                   'subdisk' => $i,
-                                 });
+               foreach my $twdev (keys %tcount) {
+                       next if (!-r $twdev.$tcount{$twdev});
+                       my $count = &count_subdisks($d, "3ware",
+                                                   $twdev.$tcount{$twdev});
+                       next if (!$count);
+                       for(my $i=0; $i<$count; $i++) {
+                               push(@rv, { 'device' => $twdev.$tcount{$twdev},
+                                           'prefix' => $twdev.$tcount{$twdev},
+                                           'desc' => '3ware physical disk '.$i,
+                                           'type' => 'scsi',
+                                           'subtype' => '3ware',
+                                           'subdisk' => $i,
+                                         });
+                               }
+                       $tcount{$twdev}++;
                        }
-               $threecount++;
                }
        elsif ($d->{'device'} =~ /^\/dev\/cciss\/(.*)$/) {
                # HP Smart Array .. add underlying disks