| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
=pod |
| 5 |
|
| 6 |
=head1 NAME |
| 7 |
|
| 8 |
check_imap_quota - connects to an IMAP account and checks the quota |
| 9 |
|
| 10 |
=head1 SYNOPSIS |
| 11 |
|
| 12 |
check_imap_quota -vV |
| 13 |
check_imap_quota -? |
| 14 |
check_imap_quota --help |
| 15 |
|
| 16 |
=head1 OPTIONS |
| 17 |
|
| 18 |
=over |
| 19 |
|
| 20 |
=item --warning <seconds> |
| 21 |
|
| 22 |
Warn if it takes longer than <seconds> to connect to the IMAP server. Default is 15 seconds. |
| 23 |
Also known as: -w <seconds> |
| 24 |
|
| 25 |
=item --critical <seconds> |
| 26 |
|
| 27 |
Return a critical status if it takes longer than <seconds> to connect to the IMAP server. Default is 30 seconds. |
| 28 |
See also: --capture-critical <messages> |
| 29 |
Also known as: -c <seconds> |
| 30 |
|
| 31 |
=item --timeout <seconds> |
| 32 |
|
| 33 |
Abort with critical status if it takes longer than <seconds> to connect to the IMAP server. Default is 60 seconds. |
| 34 |
The difference between timeout and critical is that, with the default settings, if it takes 45 seconds to |
| 35 |
connect to the server then the connection will succeed but the plugin will return CRITICAL because it took longer |
| 36 |
than 30 seconds. |
| 37 |
Also known as: -t <seconds> |
| 38 |
|
| 39 |
=item --hostname <server> |
| 40 |
|
| 41 |
Address or name of the IMAP server. Examples: mail.server.com, localhost, 192.168.1.100 |
| 42 |
Also known as: -H <server> |
| 43 |
|
| 44 |
=item --port <number> |
| 45 |
|
| 46 |
Service port on the IMAP server. Default is 143. If you use SSL, default is 993. |
| 47 |
Also known as: -p <number> |
| 48 |
|
| 49 |
=item --username <username> |
| 50 |
|
| 51 |
=item --password <password> |
| 52 |
|
| 53 |
Username and password to use when connecting to IMAP server. |
| 54 |
Also known as: -U <username> -P <password> |
| 55 |
|
| 56 |
=item --mailbox <mailbox> |
| 57 |
|
| 58 |
Use this option to specify the mailbox to search for messages. Default is INBOX. |
| 59 |
Also known as: -m <mailbox> |
| 60 |
|
| 61 |
=item --ssl |
| 62 |
|
| 63 |
=item --nossl |
| 64 |
|
| 65 |
Enable SSL protocol. Requires IO::Socket::SSL. |
| 66 |
|
| 67 |
Using this option automatically changes the default port from 143 to 993. You can still |
| 68 |
override this from the command line using the --port option. |
| 69 |
|
| 70 |
Use the nossl option to turn off the ssl option. |
| 71 |
|
| 72 |
=item --hires |
| 73 |
|
| 74 |
Use the Time::HiRes module to measure time, if available. |
| 75 |
|
| 76 |
=item --verbose |
| 77 |
|
| 78 |
Display additional information. Useful for troubleshooting. Use together with --version to see the default |
| 79 |
warning and critical timeout values. |
| 80 |
|
| 81 |
If the selected mailbox was not found, you can use verbosity level 3 (-vvv) to display a list of all |
| 82 |
available mailboxes on the server. |
| 83 |
|
| 84 |
Also known as: -v |
| 85 |
|
| 86 |
=item --version |
| 87 |
|
| 88 |
Display plugin version and exit. |
| 89 |
Also known as: -V |
| 90 |
|
| 91 |
=item --help |
| 92 |
|
| 93 |
Display this documentation and exit. Does not work in the ePN version. |
| 94 |
Also known as: -h |
| 95 |
|
| 96 |
=item --usage |
| 97 |
|
| 98 |
Display a short usage instruction and exit. |
| 99 |
|
| 100 |
=back |
| 101 |
|
| 102 |
=head1 EXAMPLES |
| 103 |
|
| 104 |
=head2 Report how many emails are in the mailbox |
| 105 |
|
| 106 |
$ check_imap_receive -H mail.server.net --username mailuser --password mailpass |
| 107 |
-s ALL --nodelete |
| 108 |
|
| 109 |
IMAP RECEIVE OK - 1 seconds, 7 found |
| 110 |
|
| 111 |
=head2 Report the email with the highest value |
| 112 |
|
| 113 |
Suppose your mailbox has some emails from an automated script and that a message |
| 114 |
from this script typically looks like this (abbreviated): |
| 115 |
|
| 116 |
To: [email protected] |
| 117 |
From: [email protected] |
| 118 |
Subject: Results of Autoscript |
| 119 |
Date: Wed, 09 Nov 2005 08:30:40 -0800 |
| 120 |
Message-ID: <[email protected]> |
| 121 |
|
| 122 |
Homeruns 5 |
| 123 |
|
| 124 |
And further suppose that you are interested in reporting the message that has the |
| 125 |
highest number of home runs, and also to leave this message in the mailbox for future |
| 126 |
checks, but remove the other matching messages with lesser values: |
| 127 |
|
| 128 |
$ check_imap_receive -H mail.server.net --username mailuser --password mailpass |
| 129 |
-s SUBJECT -s "Results of Autoscript" --capture-max "Homeruns (\d+)" --nodelete-captured |
| 130 |
|
| 131 |
IMAP RECEIVE OK - 1 seconds, 3 found, 1 captured, 5 max, 2 deleted |
| 132 |
|
| 133 |
=head2 Troubleshoot your search parameters |
| 134 |
|
| 135 |
Add the --nodelete and --imap-retries=1 parameters to your command line. |
| 136 |
|
| 137 |
=head1 EXIT CODES |
| 138 |
|
| 139 |
Complies with the Nagios plug-in specification: |
| 140 |
0 OK The plugin was able to check the service and it appeared to be functioning properly |
| 141 |
1 Warning The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly |
| 142 |
2 Critical The plugin detected that either the service was not running or it was above some "critical" threshold |
| 143 |
3 Unknown Invalid command line arguments were supplied to the plugin or the plugin was unable to check the status of the given hosts/service |
| 144 |
|
| 145 |
=head1 NAGIOS PLUGIN NOTES |
| 146 |
|
| 147 |
Nagios plugin reference: http://nagiosplug.sourceforge.net/developer-guidelines.html |
| 148 |
|
| 149 |
This plugin does NOT use Nagios DEFAULT_SOCKET_TIMEOUT (provided by utils.pm as $TIMEOUT) because |
| 150 |
the path to utils.pm must be specified completely in this program and forces users to edit the source |
| 151 |
code if their install location is different (if they realize this is the problem). You can view |
| 152 |
the default timeout for this module by using the --verbose and --version options together. The |
| 153 |
short form is -vV. |
| 154 |
|
| 155 |
Other than that, it attempts to follow published guidelines for Nagios plugins. |
| 156 |
|
| 157 |
=head1 SEE ALSO |
| 158 |
|
| 159 |
http://nagios.org/ |
| 160 |
http://search.cpan.org/~djkernen/Mail-IMAPClient-2.2.9/IMAPClient.pod |
| 161 |
http://search.cpan.org/~markov/Mail-IMAPClient-3.00/lib/Mail/IMAPClient.pod |
| 162 |
|
| 163 |
=head1 CHANGES |
| 164 |
|
| 165 |
Fri Nov 11 04:53:09 AST 2011 |
| 166 |
+ version 0.1 created with quota code contributed by Johan Romme |
| 167 |
|
| 168 |
Tue Dec 20 17:38:04 PST 2011 |
| 169 |
+ fixed bug where a quota of 0 was reported as an incorrect response from the server, thanks to Eike Arndt |
| 170 |
+ version 0.2 |
| 171 |
|
| 172 |
=head1 AUTHOR |
| 173 |
|
| 174 |
Jonathan Buhacoff <[email protected]> |
| 175 |
|
| 176 |
=head1 COPYRIGHT AND LICENSE |
| 177 |
|
| 178 |
Copyright (C) 2011 Jonathan Buhacoff |
| 179 |
|
| 180 |
This program is free software; you can redistribute it and/or modify |
| 181 |
it under the terms of the GNU General Public License as published by |
| 182 |
the Free Software Foundation; either version 3 of the License, or |
| 183 |
(at your option) any later version. |
| 184 |
|
| 185 |
This program is distributed in the hope that it will be useful, |
| 186 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 187 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 188 |
GNU General Public License for more details. |
| 189 |
|
| 190 |
You should have received a copy of the GNU General Public License |
| 191 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 192 |
|
| 193 |
http://www.gnu.org/licenses/gpl.txt |
| 194 |
|
| 195 |
=cut |
| 196 |
|