Hi,
I'm writing a simple check for a jbod device. If all the drives come back with a status sign of "HEALTHY" then I print an "OK" statement. If it doesn't come with that status, then I print "CRITICAL". Very simple. My script prints CRITICAL when the condition is met but it doesn't print anything when all drives are healthy.
THanks,
-twantrd
I'm writing a simple check for a jbod device. If all the drives come back with a status sign of "HEALTHY" then I print an "OK" statement. If it doesn't come with that status, then I print "CRITICAL". Very simple. My script prints CRITICAL when the condition is met but it doesn't print anything when all drives are healthy.
Code:
#!/usr/bin/perl
# Read the contents of the file that has the status of all drives
my $file="/tmp/drive_stats";
# Save contents of file into an array and if it doesn't match HEALTHY, do something
open (FILE, $file) || die "Cannot open file $!";
@list=<FILE>;
close FILE;
@health=grep(!/HEALTHY/,@list);
# Array is not empty
if (@health) {
print "CRITICAL: Problem with drive: @health";
}
else {
print "OK: All drives are healthy";
}
THanks,
-twantrd