check_email_delivery plugin issue probably syntax

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

check_email_delivery plugin issue probably syntax

Post 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 :)
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_email_delivery plugin issue probably syntax

Post by tgriep »

Could you post how you are running the command and the errors you are receiving?
Be sure to check out our Knowledgebase for helpful articles and solutions!
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Re: check_email_delivery plugin issue probably syntax

Post 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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_email_delivery plugin issue probably syntax

Post 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?
Former Nagios employee
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Re: check_email_delivery plugin issue probably syntax

Post 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>]
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_email_delivery plugin issue probably syntax

Post 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

Be sure to check out our Knowledgebase for helpful articles and solutions!
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Re: check_email_delivery plugin issue probably syntax

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_email_delivery plugin issue probably syntax

Post by lmiltchev »

Sounds good.
Be sure to check out our Knowledgebase for helpful articles and solutions!
brdr
Posts: 312
Joined: Mon Jun 02, 2014 12:49 pm

Re: check_email_delivery plugin issue probably syntax

Post 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?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_email_delivery plugin issue probably syntax

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked