]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/monitoring/plugins/check_emails
Add status engine website
[perso/Immae/Config/Nix.git] / modules / private / monitoring / plugins / check_emails
index 5a8453e70f7aa82b182e54c4c77a2724728ca15d..534e5a5096bf3943c766ba4c92ac15e529510923 100755 (executable)
@@ -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);
 }