Skip to content

Commit

Permalink
Fix default Percent_Lifetime_Remain threshold handling when -w is giv…
Browse files Browse the repository at this point in the history
…en (issue #92) (#93)

Address issue when threshold is not set in the following case:
  check_smart -i auto -g '/dev/sda' -w Reallocated_Sector_Ct=250 -l

  Instead of 90, the threshold is 0 when -w is given without
  Percent_Lifetime_Remain threshold.
  • Loading branch information
ymartin-ovh authored Sep 20, 2023
1 parent 4e2d7d2 commit 394f96e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion check_smart.pl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
# Apr 29, 2023: Nick Bertrand - Show drive(s) causing UNKNOWN status using -g/--global check (6.14.0)
# Apr 29, 2023: Claudio Kuenzler - Add possibility to hide serial number (--hide-sn) (6.14.0)
# Apr 29, 2023: Claudio Kuenzler - Add default check on Load Cycle Count (ignore using --skip-load-cycles) (6.14.0)
# Sep 20, 2023: Yannick Martin - Fix default Percent_Lifetime_Remain threshold handling when -w is given

use strict;
use Getopt::Long;
Expand Down Expand Up @@ -228,7 +229,6 @@

# warning threshold list (for raw checks)
my $warn_list = $opt_w // '';
$warn_list = $opt_w // 'Percent_Lifetime_Remain=90' if $opt_l;
my @warn_list = split /,/, $warn_list;
my %warn_list;
my $warn_key;
Expand All @@ -237,6 +237,9 @@
($warn_key, $warn_value) = split /=/, $warn_element;
$warn_list{ $warn_key } = $warn_value;
}
if ($opt_l && ! exists $warn_list{'Percent_Lifetime_Remain'}) {
$warn_list{'Percent_Lifetime_Remain'} = 90;
}

# For backward compatibility, add -b parameter to warning thresholds
if ($opt_b) {
Expand Down

0 comments on commit 394f96e

Please sign in to comment.