From dc59dedff63993a6f4f6bb73eccdc269b109f366 Mon Sep 17 00:00:00 2001 From: Claudio Kuenzler Date: Fri, 10 Dec 2021 08:37:06 +0100 Subject: [PATCH] 6.12.0 (#75) * Security fix in trailing path for pseudo-devices * Additional anchor for security * Update help * Add Erase_Fail_Count_Total to default raw list * Fix NVMe perfdata (issue 74) * Release today --- check_smart.pl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/check_smart.pl b/check_smart.pl index 7f35aa3..2755ad9 100755 --- a/check_smart.pl +++ b/check_smart.pl @@ -50,13 +50,14 @@ # Apr 8, 2021: Claudio Kuenzler - Fix regex for pseudo-devices (6.9.1) # Jul 6, 2021: Bernhard Bittner - Add aacraid devices (6.10.0) # Oct 4, 2021: Claudio Kuenzler + Peter Newman - Handle dots in NVMe attributes, prioritize (order) alerts (6.11.0) +# Dec 10, 2021: Claudio Kuenzler - Sec fix in path for pseudo-devices, add Erase_Fail_Count_Total, fix NVMe perfdata (6.12.0) use strict; use Getopt::Long; use File::Basename qw(basename); my $basename = basename($0); -my $revision = '6.11.0'; +my $revision = '6.12.0'; # Standard Nagios return codes my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); @@ -117,7 +118,7 @@ foreach my $opt_dl (@dev){ warn "Found $opt_dl\n" if $opt_debug; - if (-b $opt_dl || -c $opt_dl || $opt_dl =~ m/^\/dev\/bus\/\d/) { + if (-b $opt_dl || -c $opt_dl || $opt_dl =~ m/^\/dev\/bus\/\d$/) { $device .= $opt_dl."|"; } else { @@ -134,7 +135,7 @@ # Allow all device types currently supported by smartctl # See http://www.smartmontools.org/wiki/Supported_RAID-Controllers - if ($opt_i =~ m/(ata|scsi|3ware|areca|hpt|aacraid|cciss|megaraid|sat|auto|nvme)/) { + if ($opt_i =~ m/^(ata|scsi|3ware|areca|hpt|aacraid|cciss|megaraid|sat|auto|nvme)$/) { $interface = $opt_i; if($interface =~ m/megaraid,\[(\d{1,2})-(\d{1,2})\]/) { $interface = ""; @@ -195,7 +196,7 @@ push(@exclude_checks, @exclude_perfdata); # raw check list -my $raw_check_list = $opt_r // 'Current_Pending_Sector,Reallocated_Sector_Ct,Program_Fail_Cnt_Total,Uncorrectable_Error_Cnt,Offline_Uncorrectable,Runtime_Bad_Block,Reported_Uncorrect,Reallocated_Event_Count'; +my $raw_check_list = $opt_r // 'Current_Pending_Sector,Reallocated_Sector_Ct,Program_Fail_Cnt_Total,Uncorrectable_Error_Cnt,Offline_Uncorrectable,Runtime_Bad_Block,Reported_Uncorrect,Reallocated_Event_Count,Erase_Fail_Count_Total'; my @raw_check_list = split /,/, $raw_check_list; push @raw_check_list, 'Percent_Lifetime_Remain' if $opt_l; @@ -441,7 +442,8 @@ @output = `$full_command`; warn "(debug) output:\n@output\n\n" if $opt_debug; my @perfdata = qw//; - warn "(debug) Raw Check List: $raw_check_list\n" if $opt_debug; + warn "(debug) Raw Check List ATA: $raw_check_list\n" if $opt_debug; + warn "(debug) Raw Check List NVMe: $raw_check_list_nvme\n" if $opt_debug; warn "(debug) Exclude List for Checks: ", join(",", @exclude_checks), "\n" if $opt_debug; warn "(debug) Exclude List for Perfdata: ", join(",", @exclude_perfdata), "\n" if $opt_debug; warn "(debug) Warning Thresholds:\n" if $opt_debug; @@ -511,7 +513,7 @@ my ($attribute_name, $raw_value) = ($1, $2); $raw_value =~ s/\s|,//g; $attribute_name =~ s/\s/_/g; - $attribute_name =~ s/.//g; + $attribute_name =~ s/\.//g; # some attributes produce irrelevant data; no need to graph them if (grep {$_ eq $attribute_name} ('Critical_Warning') ){ @@ -796,7 +798,7 @@ sub print_help { print " -i/--interface: device's interface type (auto|ata|scsi|nvme|3ware,N|areca,N|hpt,L/M/N|aacraid,H,L,ID|cciss,N|megaraid,N)\n"; print " (See http://www.smartmontools.org/wiki/Supported_RAID-Controllers for interface convention)\n"; print " -r/--raw Comma separated list of ATA or NVMe attributes to check\n"; - print " ATA default: Current_Pending_Sector,Reallocated_Sector_Ct,Program_Fail_Cnt_Total,Uncorrectable_Error_Cnt,Offline_Uncorrectable,Runtime_Bad_Block,Command_Timeout\n"; + print " ATA default: Current_Pending_Sector,Reallocated_Sector_Ct,Program_Fail_Cnt_Total,Uncorrectable_Error_Cnt,Offline_Uncorrectable,Runtime_Bad_Block,Reported_Uncorrect,Reallocated_Event_Count\n"; print " NVMe default: Media_and_Data_Integrity_Errors\n"; print " -b/--bad: Threshold value for Current_Pending_Sector for ATA and 'grown defect list' for SCSI drives\n"; print " -w/--warn Comma separated list of thresholds for ATA drives (e.g. Reallocated_Sector_Ct=10,Current_Pending_Sector=62)\n";