|
66 | 66 | # Jun 12, 2025: Alexander Kanevskiy - Add usbjmicron devices (6.16.0) |
67 | 67 | # Dec 15, 2025: Florian Sager - Fix evaluating ATA Error Count: 0 as a warning (6.17.0) |
68 | 68 | # Dec 15, 2025: Philippe Beaumont - Add areca devices (6.17.0) |
| 69 | +# Apr 21, 2026: Claudio Kuenzler - Fix sys path for sudo command (6.17.1) |
69 | 70 |
|
70 | 71 | use strict; |
71 | 72 | use Getopt::Long; |
72 | 73 | use File::Basename qw(basename); |
73 | 74 |
|
74 | 75 | my $basename = basename($0); |
75 | | -my $revision = '6.17.0'; |
| 76 | +my $revision = '6.17.1'; |
76 | 77 |
|
77 | 78 | # Standard Nagios return codes |
78 | 79 | my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); |
|
117 | 118 | exit $ERRORS{'OK'}; |
118 | 119 | } |
119 | 120 |
|
| 121 | +my $sudo_command = ''; |
| 122 | +my $smart_command = undef; |
| 123 | + |
| 124 | +foreach my $path (@sys_path) { |
| 125 | + $sudo_command = "$path/sudo" if ($sudo_command eq '' && -x "$path/sudo"); |
| 126 | + $smart_command = "$path/smartctl" if (!defined($smart_command) && -x "$path/smartctl"); |
| 127 | + last if ($sudo_command ne '' && defined($smart_command)); |
| 128 | +} |
| 129 | + |
| 130 | +if (!defined($smart_command)) { |
| 131 | + print "UNKNOWN - Could not find executable smartctl in " . join(", ", @sys_path) . "\n"; |
| 132 | + exit $ERRORS{'UNKNOWN'}; |
| 133 | +} |
| 134 | + |
| 135 | +if ($sudo_command ne '') { |
| 136 | + $smart_command = "$sudo_command $smart_command"; |
| 137 | +} |
| 138 | + |
120 | 139 | my ($device, $interface) = qw// // ''; |
121 | 140 | if ($opt_d || $opt_g ) { |
122 | 141 | unless($opt_i){ |
|
211 | 230 | exit $ERRORS{'UNKNOWN'}; |
212 | 231 | } |
213 | 232 |
|
214 | | -my $smart_command = undef; |
215 | | -foreach my $path (@sys_path) { |
216 | | - if (-x "$path/smartctl") { |
217 | | - $smart_command = "sudo $path/smartctl"; |
218 | | - last; |
219 | | - } |
220 | | -} |
221 | | - |
222 | | -if (!defined($smart_command)) { |
223 | | - print "UNKNOWN - Could not find executable smartctl in " . join(", ", @sys_path) . "\n"; |
224 | | - exit $ERRORS{'UNKNOWN'}; |
225 | | -} |
226 | 233 |
|
227 | 234 | my $exit_status = 'OK'; |
228 | 235 | my $exit_status_local = 'OK'; |
|
0 commit comments