Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_imap_mailbox
117141
File | Description |
---|---|
check_imap_mailbox.gz | check_imap_mailbox |
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
Check a IMAP mailbox for new mails
Reviews (2)
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("\0" . $options->{user} . "\0" . $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 exists\n";
exit 2;
}
@@ -90,12 +92,12 @@
## Now check the results
if ( $unseen == 0 )
{
- print "OK: $unseen unread messages";
+ print "OK: $unseen unread messages|'messages'=$unseen\n";
exit 0;
}
else
{
- print "CRIT: $unseen unread messages in $options->{folder}";
+ print "CRIT: $unseen unread messages in $options->{folder}|'messages'=$unseen\n";
exit 2;
}
--- 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("\0" . $options->{user} . "\0" . $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 exists\n";
exit 2;
}
@@ -90,12 +92,12 @@
## Now check the results
if ( $unseen == 0 )
{
- print "OK: $unseen unread messages";
+ print "OK: $unseen unread messages|'messages'=$unseen\n";
exit 0;
}
else
{
- print "CRIT: $unseen unread messages in $options->{folder}";
+ print "CRIT: $unseen unread messages in $options->{folder}|'messages'=$unseen\n";
exit 2;
}
bysangayya.alagundimath, January 3, 2012
./check_imap_mailbox.pl --host= --user= --pass= --folder=Inbox
and getting the error
CRIT: folder Inbox doesn't exists
let me know if there is any solution for this
and getting the error
CRIT: folder Inbox doesn't exists
let me know if there is any solution for this