Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug output for raw check list, fix --hide-serial in debug output #94

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions check_smart.pl
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@
# Apr 29, 2023: Nick Bertrand - Show drive(s) causing UNKNOWN status using -g/--global check (6.14.0)
# Apr 29, 2023: Claudio Kuenzler - Add possibility to hide serial number (--hide-sn) (6.14.0)
# Apr 29, 2023: Claudio Kuenzler - Add default check on Load Cycle Count (ignore using --skip-load-cycles) (6.14.0)
# Sep 20, 2023: Yannick Martin - Fix default Percent_Lifetime_Remain threshold handling when -w is given
# Sep 20, 2023: Yannick Martin - Fix default Percent_Lifetime_Remain threshold handling when -w is given (6.14.1)
# Sep 20, 2023: Claudio Kuenzler - Fix debug output for raw check list, fix --hide-serial in debug output (6.14.1)

use strict;
use Getopt::Long;
use File::Basename qw(basename);

my $basename = basename($0);
my $revision = '6.14.0';
my $revision = '6.14.1';

# Standard Nagios return codes
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
Expand Down Expand Up @@ -283,6 +284,7 @@
warn "###########################################################\n\n\n" if $opt_debug;

my $full_command = "$smart_command -d $interface -Hi $device";
$full_command = "$smart_command -d $interface -Hi $device -q noserial" if $opt_hide_sn;
warn "(debug) executing:\n$full_command\n\n" if $opt_debug;

my @output = `$full_command`;
Expand Down Expand Up @@ -473,7 +475,7 @@
@output = `$full_command`;
warn "(debug) output:\n@output\n\n" if $opt_debug;
my @perfdata = qw//;
warn "(debug) Raw Check List ATA: $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;
Expand Down Expand Up @@ -837,7 +839,7 @@ sub print_revision {

sub print_help {
print_revision($basename,$revision);
print "\nUsage: $basename {-d=<block device>|-g=<block device glob>} -i=(auto|ata|scsi|3ware,N|areca,N|hpt,L/M/N|aacraid,H,L,ID|cciss,N|megaraid,N) [-r list] [-w list] [-b N] [-e list] [-E list] [--debug]\n\n";
print "\nUsage: $basename {-d=<block device>|-g=<block device glob>} -i=(auto|ata|scsi|3ware,N|areca,N|hpt,L/M/N|aacraid,H,L,ID|cciss,N|megaraid,N) [-r list] [-w list] [-b N] [-e list] [-E list] [-s] [-l] [--debug]\n\n";
print "At least one of the below. -d supersedes -g\n";
print " -d/--device: a physical block device to be SMART monitored, eg /dev/sda. Pseudo-device /dev/bus/N is allowed.\n";
print " -g/--global: a glob pattern name of physical devices to be SMART monitored\n";
Expand Down