Page 1 of 2

check_email_delivery plugin issue probably syntax

Posted: Tue Mar 24, 2015 10:04 am
by brdr
Hi,

We have Nagios XI2014R2.3

I have combed through forum, and visited http://www.openparty.net/2008/software/ ... ivery.html and still can't get my check_email_delivery from the command line to work. Once i get the command line to work it should work in Nagios using ARGs. Here are my commands below. Note: the check_smtp_send and check_imap_receive plugins work as expected if running them independently.

What am I missing?

1) without TOKEN
./check_email_delivery –-plugin "/usr/local/nagios/libexec/check_smtp_send -H snmptserver --mailto [email protected] --mailfrom [email protected] -–header 'Subject: Nagios Monitor Test'" –-plugin "/usr/local/nagios/libexec/check_imap_receive -H imapserver.com -U user -P pwd -s SUBJECT -s 'Nagios Monitor Test'"

2) using default TOKEN
./check_email_delivery –-plugin "/usr/local/nagios/libexec/check_smtp_send -H snmptserver --mailto [email protected] --mailfrom [email protected] -–header 'Subject: Nagios Monitor Test %TOKEN1%.'" –-plugin "/usr/local/nagios/libexec/check_imap_receive -H imapserver.com -U user -P pwd -s SUBJECT -s 'Nagios Monitor Test %TOKEN1%.'"

As usual, thanks for you help :)

Re: check_email_delivery plugin issue probably syntax

Posted: Tue Mar 24, 2015 2:03 pm
by tgriep
Could you post how you are running the command and the errors you are receiving?

Re: check_email_delivery plugin issue probably syntax

Posted: Tue Mar 24, 2015 2:18 pm
by brdr
I'm running the command from the /usr/local/nagios/libexec directory.

The output is:

Usage 1: ./check_email_delivery -H host
--mailto [email protected] --mailfrom [email protected] --body 'message'
--username username --password password
[-w <seconds>] [-c <seconds>]
[--imap-check-interval <seconds> ] [--imap-retries <times> ]
Usage 2: ./check_email_delivery
-p 'first plugin command with %TOKEN1% embedded'
-p 'second plugin command with %TOKEN1% embedded'
[-w <seconds1>,<seconds2>] [-c <seconds1>,<seconds2>]

I tried running both usage scenarios without any luck.

Re: check_email_delivery plugin issue probably syntax

Posted: Tue Mar 24, 2015 2:28 pm
by tmcdonald
I'm a bit confused here. Is that the output for the first command you posted or the second? Can you please show both the commands you are running and the output immediately following?

Re: check_email_delivery plugin issue probably syntax

Posted: Tue Mar 24, 2015 2:44 pm
by brdr
Sorry... looking at output does get confusing. Simply:

These 2 commands have the exact same behavior - the output for both of these commands is in CODE BLOCK....
1) without TOKEN
./check_email_delivery –-plugin "/usr/local/nagios/libexec/check_smtp_send -H snmptserver --mailto [email protected] --mailfrom [email protected] -–header 'Subject: Nagios Monitor Test'" –-plugin "/usr/local/nagios/libexec/check_imap_receive -H imapserver.com -U user -P pwd -s SUBJECT -s 'Nagios Monitor Test'"

2) using default TOKEN
./check_email_delivery –-plugin "/usr/local/nagios/libexec/check_smtp_send -H snmptserver --mailto [email protected] --mailfrom [email protected] -–header 'Subject: Nagios Monitor Test %TOKEN1%.'" –-plugin "/usr/local/nagios/libexec/check_imap_receive -H imapserver.com -U user -P pwd -s SUBJECT -s 'Nagios Monitor Test %TOKEN1%.'"

Code: Select all

Usage 1: ./check_email_delivery -H host
        --mailto [email protected] --mailfrom [email protected] --body 'message'
        --username username --password password
        [-w <seconds>] [-c <seconds>]
        [--imap-check-interval <seconds> ] [--imap-retries <times> ]
Usage 2: ./check_email_delivery
        -p 'first plugin command with %TOKEN1% embedded'
        -p 'second plugin command with %TOKEN1% embedded'
        [-w <seconds1>,<seconds2>] [-c <seconds1>,<seconds2>]

Re: check_email_delivery plugin issue probably syntax

Posted: Tue Mar 24, 2015 3:07 pm
by tgriep
I found the following in the README file that came with the plugin, it this what you are looking for?

Code: Select all

The email delivery plugin I wrote uses two other plugins
(smtp send and imap receive), also included, to send a message
to an email account and then check that account for the message
and delete it. The plugin times how long it takes for the
message to be delivered and the warning and critical thresholds
are for this elapsed time. 

A few notes:

1. I tried to use the check_smtp plugin for sending mail.  I
can do it on the command line but I can't get the newlines to
happen from the nagios config file (\n doesn't seem to work so smtp
server waits for the '.' but doesn't get it like it does when I
use single quote and newlines from the command line).   So if
you know how to get the check_smtp plugin to send a message from
the nagios config, that one could be used instead of the
check_smtp_send plugin included here (and please let me know)


2. I looked at check_mail.pl by bledi51 and its pretty good,
and also conforms better to nagios perl plugin guidelnes than
mine does.  So I'm going to be revising my plugins to conform
more. 






Finally, usage example from my own nagios config:

define command{
	command_name	check_email_delivery
	command_line	$USER1$/check_email_delivery -H $HOSTADDRESS$ --mailfrom $ARG3$ --mailto $ARG4$ --username $ARG5$ --password $ARG6$ --libexec $USER1$ -w $ARG1$ -c $ARG2$
	}

define service{
        use                             generic-service
        host_name                       mail.your.net
        service_description             EMAIL DELIVERY
        check_command                   [email protected][email protected][email protected]!password
        }


A new usage example equivalent to the old one but using the new --plugins and --token options:

define command{
	command_name	check_email_delivery
	command_line	$USER1$/check_email_delivery -p '$USER1$/check_smtp_send -H $HOSTADDRESS$ --mailfrom $ARG3$ --mailto $ARG4$ -U $ARG5$ -P $ARG6$ --subject "Nagios %TOKEN1%" -w $ARG1$ -c $ARG2$' -p '$USER1$/check_imap_receive -H $HOSTADDRESS$ -U $ARG5$ -P $ARG6$ -s SUBJECT -s "Nagios %TOKEN1%" -w $ARG1$ -c $ARG2$' -w $ARG1$,$ARG1$ -c $ARG2$,$ARG2$
	}

define service{
        use                             generic-service
        host_name                       mail.your.net
        service_description             EMAIL DELIVERY
        check_command                   [email protected][email protected][email protected]!password
        }


References to similar plugins:

pop3(s) email matching plugin by kkvenkit
check_mail.pl by bledi51
check_email_loop.pl by ryanwilliams
check_pop.pl and check_imap.pl by http://www.jhweiss.de/software/nagios.html


Re: check_email_delivery plugin issue probably syntax

Posted: Tue Mar 24, 2015 3:20 pm
by brdr
Thanks tgriep! I will try this tomorrow. It looks very similiar to what I was trying but maybe missing something. Will circle back with findings.

Re: check_email_delivery plugin issue probably syntax

Posted: Tue Mar 24, 2015 4:42 pm
by lmiltchev
Sounds good.

Re: check_email_delivery plugin issue probably syntax

Posted: Wed Mar 25, 2015 3:20 pm
by brdr
I’ve made sure the check_smtp_send, check_imap_receive, and check_email_delivery where correct version using plugin that jbuhacoff wrote.

$ ./check_email_delivery --plugin "/usr/local/nagios/libexec/check_smtp_send -H x.x.x.x --mailfrom [email protected] --mailto [email protected] --header 'Subject: NagiosC' -w 3 -c 6" --plugin "/usr/local/nagios/libexec/check_imap_receive -H imap.com -p 143 -x -P 'x -s SUBJECT -s 'NagiosC' --nodelete --imap-check-interval 4 --imap-retries 4 -w 2 -c 4"

Now when I run this command I get:

EMAIL DELIVERY CRITICAL - plugin 1 failed: IMAP RECEIVE CRITICAL - found less than 1; 13 seconds, 0 found, 0 captured | elapsed=13s found=0messages captured=0messages

If I run the commands individually, first the smtp send, then after the imap receive it all works fine. What I’m seeing is that the check_email_delivery command is NOT executing the smtp send (i have even modified code to add verbosity when calling check_smtp_send in the delivery program and still nothing). I can change check_smtp_send to any other command and still get the same output above.

Any idea why the smtp_send is NOT getting executed?

Re: check_email_delivery plugin issue probably syntax

Posted: Wed Mar 25, 2015 4:35 pm
by tgriep
Try the command like this. Substitute username and passwords for your server.

Code: Select all

./check_email_delivery -p '/usr/local/nagios/libexec/check_smtp_send -H x.x.x.x --mailfrom [email protected] --mailto [email protected] --subject "Subject: NagiosC" -w 3 -c 6' -p '/usr/local/nagios/libexec/check_imap_receive -H imap.com -p 143 -U <USERNAME> -P <PASSWORD> -s HEADER -s "NagiosC" --nodelete --imap-check-interval 4 --imap-retries 4 -w 2 -c 4'
Could you show us how you ran the commands individually?