Skip to content

Commit

Permalink
6.12.0 (#75)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Napsty authored Dec 10, 2021
1 parent 578586b commit dc59ded
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions check_smart.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -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 = "";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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') ){
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit dc59ded

Please sign in to comment.