Use disk IDs instead of device paths where possible
authorJamie Cameron <jcameron@webmin.com>
Tue, 19 Jan 2010 07:45:01 +0000 (23:45 -0800)
committerJamie Cameron <jcameron@webmin.com>
Tue, 19 Jan 2010 07:45:01 +0000 (23:45 -0800)
smart-status/CHANGELOG
smart-status/smart-status-lib.pl
smart-status/status_monitor.pl

index 12ec95c..4355aaf 100644 (file)
@@ -15,3 +15,5 @@ Added support for systems with both old and new 3ware cards.
 Added support for FreeBSD and OSX systems, if they have the smartctl package installed.
 ---- Changes since 1.490 ----
 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.
index aea7d7e..922c461 100755 (executable)
@@ -69,6 +69,7 @@ foreach my $d (&fdisk::list_disks_partitions()) {
                                            'type' => 'scsi',
                                            'subtype' => '3ware',
                                            'subdisk' => $i,
+                                           'id' => $d->{'id'},
                                          });
                                }
                        $tcount{$twdev}++;
@@ -84,6 +85,7 @@ foreach my $d (&fdisk::list_disks_partitions()) {
                                    'type' => 'scsi',
                                    'subtype' => 'cciss',
                                    'subdisk' => $i,
+                                   'id' => $d->{'id'},
                                  });
                        }
                }
index 12265f4..84aa0d4 100755 (executable)
@@ -17,13 +17,9 @@ else {
 # Check the drive status
 sub status_monitor_status
 {
-if (!-r $_[1]->{'drive'}) {
-       # Could not find device
-       return { 'up' => -1,
-                'desc' => $text{'monitor_nosuch'} };
-       }
 local @drives = &list_smart_disks_partitions();
-local ($d) = grep { $_->{'device'} eq $_[1]->{'drive'} &&
+local ($d) = grep { ($_->{'device'} eq $_[1]->{'drive'} ||
+                    $_->{'id'} eq $_[1]->{'drive'}) &&
                    $_->{'subdisk'} eq $_[1]->{'subdisk'} } @drives;
 if (!$d) {
        # Not in list?!
@@ -73,14 +69,17 @@ sub status_monitor_dialog
 {
 local $rv;
 local @drives = &list_smart_disks_partitions();
-local ($inlist) = grep { $_->{'device'} eq $_[1]->{'drive'} &&
+local ($inlist) = grep { ($_->{'device'} eq $_[1]->{'drive'} ||
+                         $_->{'id'} eq $_[1]->{'drive'}) &&
                         $_->{'subdisk'} eq $_[1]->{'subdisk'} } @drives;
 $inlist = 1 if (!$_[1]->{'drive'});
 $rv .= &ui_table_row($text{'monitor_drive'},
-      &ui_select("drive", !$_[1]->{'drive'} ? $drives[0]->{'device'} :
-                          $inlist ? $inlist->{'device'}.':'.$inlist->{'subdisk'} :
-                                    undef,
-                [ (map { [ $_->{'device'}.':'.$_->{'subdisk'},
+      &ui_select("drive",
+                !$_[1]->{'drive'} ? $drives[0]->{'device'} :
+                $inlist ? ($inlist->{'id'} || $inlist->{'device'}).':'.
+                            $inlist->{'subdisk'} :
+                          undef,
+                [ (map { [ ($_->{'id'} || $_->{'device'}).':'.$_->{'subdisk'},
                           $_->{'desc'}.($_->{'model'} ?
                                " ($_->{'model'})" : "") ] } @drives),
                   [ "", $text{'monitor_other'} ] ]).