X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprivate%2Fmonitoring%2Fplugins%2Fcheck_emails;h=534e5a5096bf3943c766ba4c92ac15e529510923;hb=a97118c489a59d723538292214efaa10dfcb96df;hp=0ee3e4e698052a3e7c7ed31f95098299ee82a33a;hpb=71a2425ed95120a6de3a41bb233b1066779d4c26;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/monitoring/plugins/check_emails b/modules/private/monitoring/plugins/check_emails index 0ee3e4e..534e5a5 100755 --- a/modules/private/monitoring/plugins/check_emails +++ b/modules/private/monitoring/plugins/check_emails @@ -37,7 +37,7 @@ my @emails_to_expect = split(/,/, $opts{'f'}); 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); } @@ -61,6 +61,7 @@ foreach my $line (@lines) { } my $output = ""; +my $old = 0; foreach my $email_from (@emails_to_expect) { my @email_split = split(/:/, $email_from); my $email = $email_split[0]; @@ -73,16 +74,17 @@ foreach my $email_from (@emails_to_expect) { 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); }