|
83 | 83 | $ENV{'BASH_ENV'}=''; |
84 | 84 | $ENV{'ENV'}=''; |
85 | 85 |
|
86 | | -my $sudo_command = ''; |
87 | | -my $smart_command = undef; |
88 | | - |
89 | | -foreach my $path (@sys_path) { |
90 | | - $sudo_command = "$path/sudo" if ($sudo_command eq '' && -x "$path/sudo"); |
91 | | - $smart_command = "$path/smartctl" if (!defined($smart_command) && -x "$path/smartctl"); |
92 | | - last if ($sudo_command ne '' && defined($smart_command)); |
93 | | -} |
94 | | - |
95 | | -if (!defined($smart_command)) { |
96 | | - print "UNKNOWN - Could not find executable smartctl in " . join(", ", @sys_path) . "\n"; |
97 | | - exit $ERRORS{'UNKNOWN'}; |
98 | | -} |
99 | | - |
100 | | -if ($sudo_command ne '') { |
101 | | - $smart_command = "$sudo_command $smart_command"; |
102 | | -} |
103 | | - |
104 | 86 | use vars qw($opt_b $opt_d $opt_g $opt_debug $opt_h $opt_i $opt_e $opt_E $opt_o $opt_r $opt_s $opt_v $opt_w $opt_q $opt_l $opt_skip_sa $opt_skip_temp $opt_skip_load_cycles $opt_skip_error_log $opt_hide_sn); |
105 | 87 | Getopt::Long::Configure('bundling'); |
106 | 88 | GetOptions( |
|
136 | 118 | exit $ERRORS{'OK'}; |
137 | 119 | } |
138 | 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 | + |
139 | 139 | my ($device, $interface) = qw// // ''; |
140 | 140 | if ($opt_d || $opt_g ) { |
141 | 141 | unless($opt_i){ |
|
0 commit comments