diff --git a/check_smart.pl b/check_smart.pl index 0d8df12..a7ca83a 100755 --- a/check_smart.pl +++ b/check_smart.pl @@ -768,12 +768,20 @@ if ($output_mode =~ "ata") { foreach my $line(@output){ next unless $line =~ /^ATA Error Count:\s(\d+)\s/; - my ($error_count) = ($1); - if ($error_count > 0){ - push(@error_messages, "ATA Error Count is non-zero ($error_count)"); - escalate_status('CRITICAL'); - push (@perfdata, "ata_errors=$error_count;;;;") + my ($attribute_name, $raw_value) = ('ata_errors', $1); + if ( ($warn_list{$attribute_name}) && ($raw_value >= $warn_list{$attribute_name}) ) { + warn "(debug) $attribute_name is non-zero ($raw_value)\n\n" if $opt_debug; + push(@warning_messages, "$attribute_name is non-zero ($raw_value)"); + escalate_status('WARNING'); + } elsif ( ($warn_list{$attribute_name}) && ($raw_value < $warn_list{$attribute_name}) ) { + warn "(debug) $attribute_name is non-zero ($raw_value) but less than $warn_list{$attribute_name}\n\n" if $opt_debug; + push(@notice_messages, "$attribute_name is non-zero ($raw_value) (but less than threshold $warn_list{$attribute_name})"); + } else { + warn "(debug) $attribute_name is non-zero ($raw_value)\n\n" if $opt_debug; + push(@warning_messages, "$attribute_name is non-zero ($raw_value)"); + escalate_status('WARNING'); } + push (@perfdata, "$attribute_name=$raw_value;;;;") } } }