my $cmd_result;
if ($local_directory ne '') {
- if (! -d $local_directory) {
+ if (@emails_to_expect and ! -d $local_directory) {
print "Emails $host UNKNOWN - Could not find local directory";
exit($STATE_UNKNOWN);
}
}
my $output = "";
+my $old = 0;
foreach my $email_from (@emails_to_expect) {
my @email_split = split(/:/, $email_from);
my $email = $email_split[0];
if ($current_date - $email_date > 60*30) {
$output = "$output$email ($found_emails{$email} from $from) ";
}
+ $old = ($current_date - $email_date) > $old ? ($current_date - $email_date) : $old;
} else {
$output = "$output$email (missing) "
}
}
if ($output ne '') {
- print "Emails $host CRITICAL - expecting emails: $output\n";
+ print "Emails $host CRITICAL - expecting emails: $output | timestamp=${old}s;;;;\n";
exit($STATE_CRITICAL);
} else {
- print "Emails $host OK\n";
+ print "Emails $host OK | timestamp=${old}s;;;;\n";
exit($STATE_OK);
}