From 11c1256d64ed48db9255531f833af11995ecd2aa Mon Sep 17 00:00:00 2001 From: Claudio Kuenzler Date: Wed, 27 Apr 2022 04:24:55 +0200 Subject: [PATCH] Allow skip temperature check (--skip-temp-check) (#83) * Allow skip temperature check (--skip-temp-check) * Update help --- check_smart.pl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/check_smart.pl b/check_smart.pl index 842d361..4166022 100755 --- a/check_smart.pl +++ b/check_smart.pl @@ -53,13 +53,14 @@ # Dec 10, 2021: Claudio Kuenzler - Sec fix in path for pseudo-devices, add Erase_Fail_Count_Total, fix NVMe perfdata (6.12.0) # Dec 10, 2021: Claudio Kuenzler - Bugfix in interface handling (6.12.1) # Dec 16, 2021: Lorenz Kaestle - Bugfix when interface parameter was missing in combination with -g (6.12.2) +# Apr 22, 2022: Claudio Kuenzler - Allow skip temperature check (--skip-temp-check) (6.13.0) use strict; use Getopt::Long; use File::Basename qw(basename); my $basename = basename($0); -my $revision = '6.12.2'; +my $revision = '6.13.0'; # Standard Nagios return codes my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); @@ -69,7 +70,7 @@ $ENV{'BASH_ENV'}=''; $ENV{'ENV'}=''; -use vars qw($opt_b $opt_d $opt_g $opt_debug $opt_h $opt_i $opt_e $opt_E $opt_r $opt_s $opt_v $opt_w $opt_q $opt_l $opt_skip_sa); +use vars qw($opt_b $opt_d $opt_g $opt_debug $opt_h $opt_i $opt_e $opt_E $opt_r $opt_s $opt_v $opt_w $opt_q $opt_l $opt_skip_sa $opt_skip_temp); Getopt::Long::Configure('bundling'); GetOptions( "debug" => \$opt_debug, @@ -87,6 +88,7 @@ "w=s" => \$opt_w, "warn=s" => \$opt_w, "l" => \$opt_l, "ssd-lifetime" => \$opt_l, "skip-self-assessment" => \$opt_skip_sa, + "skip-temp-check" => \$opt_skip_temp, ); if ($opt_v) { @@ -102,7 +104,7 @@ my ($device, $interface) = qw// // ''; if ($opt_d || $opt_g ) { unless($opt_i){ - print "must specify an interface for $opt_d using -i/--interface!\n\n" if $opt_d; + print "must specify an interface for $opt_d using -i/--interface!\n\n" if $opt_d; print "must specify an interface for $opt_g using -i/--interface!\n\n" if $opt_g; print_help(); exit $ERRORS{'UNKNOWN'}; @@ -681,10 +683,12 @@ if($current_temperature){ if($max_temperature){ push (@perfdata, "temperature=$current_temperature;;$max_temperature") if $opt_d; - if($current_temperature > $max_temperature){ - warn "(debug) Disk temperature is greater than max ($current_temperature > $max_temperature)\n\n" if $opt_debug; - push(@error_messages, 'Disk temperature is higher than maximum'); - escalate_status('CRITICAL'); + unless($opt_skip_temp) { + if($current_temperature > $max_temperature){ + warn "(debug) Disk temperature is greater than max ($current_temperature > $max_temperature)\n\n" if $opt_debug; + push(@error_messages, 'Disk temperature is higher than maximum'); + escalate_status('CRITICAL'); + } } } else{ @@ -822,6 +826,7 @@ sub print_help { print " -s/--selftest: Enable self-test log check\n"; print " -l/--ssd-lifetime: Check attribute 'Percent_Lifetime_Remain' available on some SSD drives\n"; print " --skip-self-assessment: Skip SMART self-assessment health status check\n"; + print " --skip-temp-check: Skip temperature comparison current vs. drive max temperature\n"; print " -h/--help: this help\n"; print " -q/--quiet: When faults detected, only show faulted drive(s) (only affects output when used with -g parameter)\n"; print " --debug: show debugging information\n";