my @cmd = ('sudo', 'megactl', '-Hv', '2>&1');
my @output = `@cmd`;
+if ($? != 0) {
+ print "WARNING: Exec failed!\n";
+ exit 2;
+}
for my $line (@output) {
if ($line =~ /^(\w+)\s+/) {
print "CRITICAL: ";
print @errs;
print "\n";
- exit 1;
+ exit 2;
} elsif (@warn) {
print "WARNING: ";
print @warn;
print "\n";
- exit 2;
+ exit 1;
}
unless (@ok) {
push @ok, "All devices OK";