Build precise queries to find exactly what you need
Press ESC to close
Helpful plugin, I just expanded it to use starttls and with better output.
— check_imap_mailbox.orig 2012-09-21 09:16:40.822833872 +0200 +++ check_imap_mailbox 2012-09-21 09:18:06.457602444 +0200 @@ -28,6 +28,7 @@ use strict; use warnings; use Mail::IMAPClient; +use MIME::Base64; use Getopt::Long;
## Print Usage if not all parameters are supplied @@ -71,16 +72,17 @@ ## Connect to server $imap = Mail::IMAPClient->new ( Server => $options->{host}, – User => $options->{user}, – Password=> $options->{pass}, Clear => 5, # Unnecessary since ‘5’ is the default – ) or die “Cannot connect to $options->{host} as $options->{user}: $@”; + ) or print “CRIT: Cannot connect to $options->{host}: $@n” and exit 2;
+$imap->has_capability(“STARTTLS”) and $imap->starttls(); + +$imap->tag_and_run(“AUTHENTICATE PLAIN ” . encode_base64(“” . $options->{user} . “” . $options->{pass})) or print “CRIT: Cannot login to $options->{host} as $options->{user}: $@n” and exit 2;
## Check if folder exists if ( ! $imap->exists($options->{folder}) ) { – print “CRIT: folder $options->{folder} doesn’t exists”; + print “CRIT: folder $options->{folder} doesn’t existsn”; exit 2; }
@@ -90,12 +92,12 @@ ## Now check the results if ( $unseen == 0 ) { – print “OK: $unseen unread messages”; + print “OK: $unseen unread messages|’messages’=$unseenn”; exit 0; } else { – print “CRIT: $unseen unread messages in $options->{folder}”; + print “CRIT: $unseen unread messages in $options->{folder}|’messages’=$unseenn”; exit 2; }
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!