Page 1 of 1

Check_Email_Delivery plugin issues

Posted: Thu Dec 13, 2018 11:17 am
by demi
Hi,

I have been trying to use this plugin to perform a check on an inbox to see if there are emails sitting. We use it as a temporary holding area for files that get imported into a document system program. Any way... i'm able to connect with our email server to send the alert with this test script line, however i'm receiveing an error right after:

EMAIL DELIVERY CRITICAL - imap failed: IMAP RECEIVE CRITICAL - Could not connect to smtp.#####.com port 143. Unable to connect to smtp.######.com:143: at /usr/local/nagios/libexec/check_imap_receive line 145.

I am using this script line:

check_email_delivery -H smtp.#####.com --username ##### --password ##### --mailto [email protected] --mailfrom [email protected] -w,,5 -c,,20

Ultimately I would like to use this as a check to see if something received was bad and causes the import to break.

Re: Check_Email_Delivery plugin issues

Posted: Thu Dec 13, 2018 11:53 am
by hbouma
I had this same issue. I ended up having to do 2 things.

Checked with our networking and made sure IMAP was open from Nagios to the mail relays on 143 (it was blocked)

changed the username to be '[email protected]'. For instance "[email protected]'

Not sure if this will help, but thought I would pass this along.

Re: Check_Email_Delivery plugin issues

Posted: Thu Dec 13, 2018 2:44 pm
by scottwilkerson
You are going to likely need to use the --imap-server flag to override the defaults as well as possibly --imap-port --imap-username --imap-password

Code: Select all

[root@localhost nagiosxi]# /usr/local/nagios/libexec/check_email_delivery --help |head -500
CHECK_EMAIL_DELIVERY(1User Contributed Perl DocumentatiCHECK_EMAIL_DELIVERY(1)



NAME
       check_email_delivery - sends email and verifies delivery

SYNOPSIS
        check_email_delivery -vV
        check_email_delivery --usage
        check_email_delivery --help

OPTIONS
       --warning <seconds>[,<smtp_seconds>,<imap_seconds>]
           Exit with WARNING if the most recent email found is older than
           <seconds>. The optional <smtp_seconds> and <imap_seconds>
           parameters will be passed on to the included plugins that are used
           for those tasks. If they are not given then they will not be passed
           on and the default for that plugin will apply.  Also known as: -w
           <seconds>[,<send>[,<recv>]]

           When using the --plugin option, only one parameter is supported (-w
           <seconds>) and it will apply to the entire process. You can specify
           a warning threshold specific to each plugin in the plugin command
           line.

           When using the --plugin option, no measuring of "most recent email"
           is done because we would not know how to read this information from
           receive plugins. This may be addressed in future versions.

       --critical <seconds>[,<smtp_seconds>,<imap_seconds>]
           Exit with CRITICAL if the most recent email found is older than
           <seconds>. The optional <smtp_seconds> and <imap_seconds>
           parameters will be passed on to the included plugins that are used
           for those tasks. If they are not given then they will not be passed
           on and the default for that plugin will apply.  Also known as: -c
           <seconds>[,<send>[,<recv>]]

           When using the --plugin option, only one parameter is supported (-c
           <seconds>) and it will apply to the entire process. You can specify
           a critical threshold specific to each plugin in the plugin command
           line.

           When using the --plugin option, no measuring of "most recent email"
           is done because we would not know how to read this information from
           receive plugins. This may be addressed in future versions.

       --timeout <seconds>
       --timeout <smtp_seconds>,<imap_seconds>
       --timeout <plugin1_seconds>,<plugin2_seconds>,...
           Exit with CRITICAL if the plugins do not return a status within the
           specified number of seconds.  When only one parameter is used, it
           applies to each plugin. When multiple parameters are used
           (separated by commas) they apply to plugins in the same order the
           plugins were specified on the command line. When using --timeout
           but not the --plugin option, the first parameter is for
           check_smtp_send and the second is for check_imap_receive.

       --alert <pluginN>
           Exit with WARNING or CRITICAL only if a warning or error
           (--warning, --critical, or --timeout) occurs for specified plugins.
           If a warning or error occurs for non-specified plugins that run
           BEFORE the specified plugins, the exit status will be UNKNOWN.  If
           a warning of error occurs for non-specified plugins that run AFTER
           the specified plugins, the exit status will not be affected.

           You would use this option if you are using check_email_delivery
           with the --plugin option and the plugins you configure each use
           different servers, for example different SMTP and IMAP servers.  By
           default, if you do not use the --alert option, if anything goes
           wrong during the email delivery check, a WARNING or CRITICAL alert
           will be issued. This means that if you define check_email_delivery
           for the SMTP server only and the IMAP server fails, Nagios will
           alert you for the SMTP server which would be misleading. If you
           define it for both the SMTP server and IMAP server and just one of
           them fails, Nagios will alert you for both servers, which would
           still be misleading.  If you have this situation, you may want to
           use the --alert option. You define the check_email_delivery check
           for both servers:  for the SMTP server (first plugin) you use
           --alert 1, and for for the IMAP server (second plugin) you use
           --alert 2. When check_email_delivery runs with --alert 1 and the
           SMTP server fails, you will get the appropriate alert. If the IMAP
           server fails it will not affect the status. When
           check_email_delivery runs with --alert 2 and the SMTP server fails,
           you will get the UNKNOWN return code. If the IMAP server generates
           an alert you will get a WARNING or CRITICAL as appropriate.

           You can repeat this option to specify multiple plugins that should
           cause an alert.  Do this if you have multiple plugins on the
           command line but some of them involve the same server.

           See also: --plugin.  Also known as: -A <pluginN>

       --wait <seconds>[,<seconds>,...]
           How long to wait between sending the message and checking that it
           was received. View default with the -vV option.

           When using the --plugin option, you can specify as many wait-
           between times as you have plugins (minus the last plugin, because
           it makes no sense to wait after running the last one). For example,
           if you use the --plugin option twice to specify an SMTP plugin and
           an IMAP plugin, and you want to wait 5 seconds between sending and
           receiving, then you would specify --wait 5. A second example, if
           you are using the --plugin option three times, then specifying -w 5
           will wait 5 seconds between the second and third plugins also. You
           can specify a different wait time of 10 seconds between the second
           and third plugins, like this:  -w 5,10.

       --hostname <server>
           Address or name of the SMTP and IMAP server. Examples:
           mail.server.com, localhost, 192.168.1.100.  Also known as: -H
           <server>

       --smtp-server <server>
           Address or name of the SMTP server. Examples: smtp.server.com,
           localhost, 192.168.1.100.  Using this option overrides the hostname
           option.

       --smtp-port <number>
           Service port on the SMTP server. Default is 25.

       --smtp-username <username>
       --smtp-password <password>
           Username and password to use when connecting to the SMTP server
           with the TLS option.  Use these options if the SMTP account has a
           different username/password than the IMAP account you are testing.
           These options take precendence over the --username and the
           --password options.

       --imap-server <server>
           Address or name of the IMAP server. Examples: imap.server.com,
           localhost, 192.168.1.100.  Using this option overrides the hostname
           option.

       --imap-port <number>
           Service port on the IMAP server. Default is 143. If you use SSL the
           default is 993.

       --imap-username <username>
       --imap-password <password>
           Username and password to use when connecting to the IMAP server.
           Use these options if the IMAP account has a different
           username/password than the SMTP account you are testing. These
           options take precendence over the --username and the --password
           options.

       --username <username>
       --password <password>
           Username and password to use when connecting to IMAP server.  Also
           known as: -U <username> -P <password>

           Also used as the username and password for SMTP when the TLS option
           is enabled.  To specify a separate set of credentials for SMTP
           authentication, see the options --smtp-username and
           --smtp-password.

       --imap-check-interval <seconds>
           How long to wait between polls of the imap-server for the specified
           mail. Default is 5 seconds.

       --imap-retries <times>
           How many times to poll the imap-server for the mail, before we give
           up. Default is 10.

       --body <message>
           Use this option to specify the body of the email message.

       --header <header>
           Use this option to set an arbitrary header in the message. You can
           use it multiple times.

       --mailto [email protected]
           You can send a message to multiple recipients by repeating this
           option or by separating the email addresses with commas (no
           whitespace allowed):

           $ check_email_delivery ... --mailto
           [email protected],[email protected] --mailfrom [email protected]

       --mailfrom [email protected]
           Use this option to set the "from" address in the email.

       --imapssl =item --noimapssl
           Use this to enable or disable SSL for the IMAP plugin.

       --smtptls =item --nosmtptls
           Use this to enable or disable TLS/AUTH for the SMTP plugin.

       --libexec
           Use this option to set the path of the Nagios libexec directory.
           The default is /usr/local/nagios/libexec. This is where this plugin
           looks for the SMTP and IMAP plugins that it depends on.

       --plugin <command>
           This is a new option introduced in version 0.5 of the
           check_email_delivery plugin.  It frees the plugin from depending on
           specific external plugins and generalizes the work done to
           determine that the email loop is operational. When using the
           --plugin option, the following options are ignored: libexec,
           imapssl, smtptls, hostname, username, password, smtp*, imap*,
           mailto, mailfrom, body, header, search.

           Use this option multiple times to specify the complete trip.
           Typically, you would use this twice to specify plugins for SMTP and
           IMAP, or SMTP and POP3.

           The output will be success if all the plugins return success. Each
           plugin should be a standard Nagios plugin.

           A random token will be automatically generated and passed to each
           plugin specified on the command line by substituting the string
           $TOKEN1$.

           Example usage:

            command_name check_email_delivery
            command_line check_email_delivery
            --plugin "$USER1$/check_smtp_send -H $ARG1$ --mailto [email protected] --mailfrom [email protected] --header 'Subject: Nagios Test %TOKEN1%.'"
            --plugin "$USER1$/check_imap_receive -H $ARG1$ -U $ARG1$ -P $ARG2$ -s SUBJECT -s 'Nagios Test %TOKEN1%.'"

           This technique allows for a lot of flexibility in configuring the
           plugins that test each part of your email delivery loop.

           See also: --token.  Also known as: -p <command>

       --token <format>
           This is a new option introduced in version 0.5 of the
           check_email_delivery plugin.  It can be used in conjunction with
           --plugin to control the tokens that are generated and passed to the
           plugins, like %TOKEN1%.

           Use this option multiple times to specify formats for different
           tokens. For example, if you want %TOKEN1% to consist of only
           alphabetical characters but want %TOKEN2% to consist of only
           digits, then you might use these options: --token aaaaaa --token
           nnnnn

           Any tokens used in your plugin commands that have not been
           specified by --token <format> will default to --token U-X-Y

           Token formats: a - alpha character (a-z) n - numeric character
           (0-9) c - alphanumeric character (a-z0-9) h - hexadecimal character
           (0-9a-f) U - unix time, seconds from epoch. eg 1193012441 X - a
           word from the pgp even list. eg aardvark Y - a word from the pgp
           odd list. eg adroitness

           Caution: It has been observed that some IMAP servers do not handle
           underscores well in the search criteria. For best results, avoid
           using underscores in your tokens. Use hyphens or commas instead.

           See also: --plugin.  Also known as: -T <format>

           The PGP word list was obtained from
           http://en.wikipedia.org/wiki/PGP_word_list

       --file <file>
           Save (append) status information into the given tab-delimited file.
           Format used:

            token  start-time      end-time        status  plugin-num      output

           Note: format may change in future versions and may become
           configurable.

           This option available as of version 0.6.2.

           Also known as: -F <file>

       --verbose
           Display additional information. Useful for troubleshooting. Use
           together with --version to see the default warning and critical
           timeout values.  Also known as: -v

       --version
           Display plugin version and exit.  Also known as: -V

       --help
           Display this documentation and exit. Does not work in the ePN
           version.  Also known as: -h

       --usage
           Display a short usage instruction and exit.

Re: Check_Email_Delivery plugin issues

Posted: Thu Dec 13, 2018 3:23 pm
by demi
scottwilkerson wrote:You are going to likely need to use the --imap-server flag to override the defaults as well as possibly --imap-port --imap-username --imap-password
I have actually tried this already and our exchange server doesn't respond. It does respond with the original settings mentioned which made me believe that there was something small i was missing. I'm reviewing our relay to see if perhaps i will find answers for this there.

Re: Check_Email_Delivery plugin issues

Posted: Thu Dec 13, 2018 4:00 pm
by scottwilkerson
demi wrote:I have actually tried this already and our exchange server doesn't respond. It does respond with the original settings mentioned which made me believe that there was something small i was missing. I'm reviewing our relay to see if perhaps i will find answers for this there.
Sounds good. You may need to enable IMAP access on the exchange server if it is not already