Skip to content

Commit

Permalink
smart-v1: fix handling of cciss when it a disk is being replaced (#483)
Browse files Browse the repository at this point in the history
* only add connectors that have not been seen for cciss

* rework seen logic to also have a ignore logic as well for cciss

* add a comment explaining why it is being ignored

* minor version bump
  • Loading branch information
VVelox committed Jul 6, 2023
1 parent 4e78072 commit f846574
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions snmp/smart-v1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ my $useSN = 1;
$Getopt::Std::STANDARD_HELP_VERSION = 1;

sub main::VERSION_MESSAGE {
print "SMART SNMP extend 0.3.0\n";
print "SMART SNMP extend 0.3.1\n";
}

sub main::HELP_MESSAGE {
Expand Down Expand Up @@ -342,7 +342,8 @@ if ( defined( $opts{g} ) ) {
. "' is failing\n";
} ## end if ( $? != 0 && !$opts{C} )
} ## end if ( -e $device )
my $seen_lines = {};
my $seen_lines = {};
my $ignore_lines = {};
while ( -e $device && $sg_process ) {
my $output = `cciss_vol_status -V $uarg $device 2> /dev/null`;
if ( $? != 0 && $output eq '' && !$opts{C} ) {
Expand Down Expand Up @@ -381,12 +382,25 @@ if ( defined( $opts{g} ) ) {
} else {
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} ) ) {
$seen_lines->{$1} = 1;
my $seen_conectors = {};
while ( $output =~ /(connector +\d+[IA]\ +box +\d+\ +bay +\d+.*)/g ) {
my $cciss_drive_line = $1;
my $connector = $cciss_drive_line;
$connector =~ s/(.*\ bay +\d+).*/$1/;
if ( !defined( $seen_lines->{$cciss_drive_line} )
&& !defined( $seen_conectors->{$connector} )
&& !defined( $ignore_lines->{$cciss_drive_line} ) )
{
$seen_lines->{$cciss_drive_line} = 1;
$seen_conectors->{$connector} = 1;
$drive_count++;
} else {
# going to be a connector we've already seen
# which will happen when it is processing replacement drives
# so save this as a device to ignore
$ignore_lines->{$cciss_drive_line} = 1;
}
}
} ## end while ( $output =~ /(connector +\d+[IA]\ +box +\d+\ +bay +\d+.*)/g)
my $drive_int = 0;
while ( $drive_int < $drive_count ) {
$drive_lines
Expand Down

0 comments on commit f846574

Please sign in to comment.