diff --git a/snmp/smart-v1 b/snmp/smart-v1 index d3b9bbdd6..9e58e1d96 100755 --- a/snmp/smart-v1 +++ b/snmp/smart-v1 @@ -269,22 +269,36 @@ if ( defined( $opts{g} ) ) { # second pass, putting the lines together my %current_disk; foreach my $arguments (@argumentsA) { + my $not_virt = 1; + + # check to see if we have a virtual device + my @virt_check = split( /\n/, `smartctl -i $arguments 2> /dev/null` ); + foreach my $virt_check_line (@virt_check) { + if ( $virt_check_line =~ /(?i)Product\:.*LOGICAL VOLUME/ ) { + $not_virt = 0; + } + } + my $name = $arguments; $name =~ s/ .*//; $name =~ s/\/dev\///; - if ( $found_disks_names{$name} == 0 ) { - # If no other devices, just name it after the base device. - $drive_lines = $drive_lines . $name . " " . $arguments . "\n"; - } else { - # if more than one, start at zero and increment, apennding comma number to the base device name - if ( defined( $current_disk{$name} ) ) { - $current_disk{$name}++; + # only add it if not a virtual RAID drive + # HP RAID virtual disks will show up with very basical but totally useless smart data + if ($not_virt) { + if ( $found_disks_names{$name} == 0 ) { + # If no other devices, just name it after the base device. + $drive_lines = $drive_lines . $name . " " . $arguments . "\n"; } else { - $current_disk{$name} = 0; + # if more than one, start at zero and increment, apennding comma number to the base device name + if ( defined( $current_disk{$name} ) ) { + $current_disk{$name}++; + } else { + $current_disk{$name} = 0; + } + $drive_lines = $drive_lines . $name . "," . $current_disk{$name} . " " . $arguments . "\n"; } - $drive_lines = $drive_lines . $name . "," . $current_disk{$name} . " " . $arguments . "\n"; - } + } ## end if ($not_virt) } ## end foreach my $arguments (@argumentsA) } ## end if ( $scan_modes->{'scan-open'} || $scan_modes...) @@ -333,25 +347,20 @@ if ( defined( $opts{g} ) ) { my $drive_count = 0; my $continue = 1; while ($continue) { - my $output = `$smartctl -A $device -d cciss,$drive_count 2> /dev/null`; + my $output = `$smartctl -i $device -d cciss,$drive_count 2> /dev/null`; if ( $? != 0 ) { $continue = 0; } else { - $continue = 0; my $add_it = 0; - # if we have smart data for this device, process it - while ( $output =~ /(?i)START OF READ SMART DATA SECTION(.*)/g && !$continue ) { - $continue = 1; - my $id; - while ( $output =~ /(?i)Serial Number:(.*)/g ) { - $id = $1; - $id =~ s/^\s+|\s+$//g; - } - if ( defined($id) && !defined( $seen_lines->{$id} ) ) { - $add_it = 1; - $seen_lines->{$id} = 1; - } - } ## end while ( $output =~ /(?i)START OF READ SMART DATA SECTION(.*)/g...) + my $id; + while ( $output =~ /(?i)Serial Number:(.*)/g ) { + $id = $1; + $id =~ s/^\s+|\s+$//g; + } + if ( defined($id) && !defined( $seen_lines->{$id} ) ) { + $add_it = 1; + $seen_lines->{$id} = 1; + } if ( $continue && $add_it ) { $drive_lines = $drive_lines @@ -365,8 +374,7 @@ if ( defined( $opts{g} ) ) { $drive_count++; } ## end while ($continue) } else { - my $sg_drive_int = 0; - my $drive_count = 0; + my $drive_count = 0; # count the connector lines, this will make sure failed are founded as well while ( $output =~ /(connector +\d.*box +\d.*bay +\d.*)/g ) { if ( !defined( $seen_lines->{$1} ) ) { @@ -377,10 +385,16 @@ if ( defined( $opts{g} ) ) { my $drive_int = 0; while ( $drive_int < $drive_count ) { $drive_lines - = $drive_lines . $cciss . '0-' . $drive_int . ' ' . $device . ' -d cciss,' . $drive_int . "\n"; + = $drive_lines + . $cciss + . $sg_int . '-' + . $drive_int . ' ' + . $device + . ' -d cciss,' + . $drive_int . "\n"; $drive_int++; - } + } ## end while ( $drive_int < $drive_count ) } ## end else [ if ( $? != 0 && $output eq '' && !$opts{C})] $sg_int++;