Skip to content

Commit

Permalink
Allow skip temperature check (--skip-temp-check) (#83)
Browse files Browse the repository at this point in the history
* Allow skip temperature check (--skip-temp-check)

* Update help
  • Loading branch information
Napsty committed Apr 27, 2022
1 parent 9619f4d commit 11c1256
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions check_smart.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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) {
Expand All @@ -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'};
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 11c1256

Please sign in to comment.