check_email_delivery not working after move to new server

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
chrisp
Posts: 71
Joined: Fri Dec 28, 2012 11:35 am

check_email_delivery not working after move to new server

Post by chrisp »

Hi All,

We've moved our NagiosXI implementation from one server to another, using the documented Nagios XI backup -> restore scripts. The new server is a new build of CentOS 6.3 from PXE boot off a CentOS mirror site, we installed Nagios in the normal way, then restored the Nagios XI backup file to the new server.

Now I note that check_email_delivery is not working any more (from the GUI or the CLI): -

Code: Select all

# /usr/local/nagios/libexec/check_email_delivery -v --timeout 300,300 --warning 300,300,300 --critical 600,600,600 --wait 1 --imap-check-interval 1 --imap-retries 300 --mailto [email protected] --mailfrom [email protected] --smtp-server smtp.example.com --smtp-port 25 --smtp-username [email protected] --smtp-password reallysecurepassword \$\$\(\[ "" \] --imap-server localhost --imap-port 143 --username [email protected] --password reallysecurepassword \$\$\(\[ "" \]
EMAIL DELIVERY CRITICAL - smtp failed: SMTP SEND CRITICAL - Could not send to [email protected]
I can send manually using telnet, so there's no firewall issue. I tried to break it down to the component parts, as "check_email_delivery -v" is not greatly helpful & using "check_smtp_send -v" I see that perl-Net-SMTP_auth was missing...

Code: Select all

# check_smtp_send -H smtp.example.com --mailto [email protected] --mailfrom [email protected] --body 'some text' --username [email protected] --password reallysecurepassword -v
Missing perl modules: Net::SMTP_auth
Fixed by: -

Code: Select all

# yum install perl-Net-SMTP_auth

Code: Select all

# check_smtp_send -H smtp.example.com --mailto [email protected] --mailfrom [email protected] --body 'some text' --username [email protected] --password reallysecurepassword -v
SMTP SEND OK - 0 seconds | elapsed=0s;15;30
banner: smtp.example.com ESMTP
The check_email_delivery script is still failing though, so I've had to hack it to hard-code "-v" in the check_smtp_send part like this: -

Code: Select all

    my $smtp_plugin = "$libexec/check_smtp_send -v";
    #$smtp_plugin = "$libexec/check_smtp_send.pl" unless -e $smtp_plugin;
Now I'm seeing "Reason: Recipient rejected or authentication failed" when running the wrapper script, but not sure why...

OK, now hardcoded to "-vvv" and I can see that when running check_email_delivery, the response to "334 VXNlcm5hbWU6" (username) actually corresponds to the check_email_delivery "--username" argument, rather than the check_smtp_send "--smtp-username" argument, but if I try to use the check_imap_receive "--imap-username" instead, the script borks. This seems like a bit of a tangled mess...
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_email_delivery not working after move to new serve

Post by scottwilkerson »

You are seeing the effects of a couple thing. I'm going to be totally honest...

First, the email delivery wizard is one of the most poorly written wizards we have, and has been placed on our TODO list to gt it fixed. The problem at present is the CCM only allows for $ARG1$ - $ARG9$ but this wizard set values all the way up to $ARG12$ which means that if you open the item in the CCM and save it, it actually truncates the additional $ARGn$'s off and deletes them...

Second, the "check command in the CCM will not work for this because of the reason stated above.

For the time being the only suggestion I can make is to re-run the wizard and it will get the information back in there and if you like we can notify you when the wizard has been updated.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
chrisp
Posts: 71
Joined: Fri Dec 28, 2012 11:35 am

Re: check_email_delivery not working after move to new serve

Post by chrisp »

Hi Scott,

Oh no, I don't think it's that. We had the joy of stumbling upon that last month, so we created a command which takes just 4 ARGs & altered our service to suit; like this: -

Code: Select all

# grep -A1 check_email_round-trip /usr/local/nagios/etc/commands.cfg        
       command_name                             check_email_round-trip
       command_line                             $USER1$/check_email_delivery $ARG1$ $ARG2$ $ARG3$ $ARG4$
ARG1="--timeout 300,300 --warning 300,300,300 --critical 600,600,600 --wait 1 --imap-check-interval 1 --imap-retries 300"
ARG2="--mailto [email protected] --mailfrom [email protected]"
ARG3="--smtp-server smtp.example.com --smtp-port 25 --smtp-username [email protected] --smtp-password reallysecurepassword \$\$\(\[ "" \]"
ARG4="--imap-server localhost --imap-port 143 --username [email protected] --password reallysecurepassword \$\$\(\[ "" \]"
User avatar
chrisp
Posts: 71
Joined: Fri Dec 28, 2012 11:35 am

Re: check_email_delivery not working after move to new serve

Post by chrisp »

Right, I've been doing some more investigating and tweaking.

The problem I was seeing with the requirement for "--username blah --password blah" and the lack of debugging, has been fixed by the following tweaks: -

Code: Select all

# diff /usr/local/nagios/libexec/check_email_delivery.bak /usr/local/nagios/libexec/check_email_delivery
129c129
<                       || $imap_server eq "" || $username eq "" || $password eq ""
---
>                       || $imap_server eq ""
176,177c176,177
< $smtp_options .= "-U $username " if defined $smtp_username and $smtp_username ne "";
< $smtp_options .= "-P $password " if defined $smtp_password and $smtp_password ne "";
---
> $smtp_options .= "-U $smtp_username " if defined $smtp_username and $smtp_username ne "";
> $smtp_options .= "-P $smtp_password " if defined $smtp_password and $smtp_password ne "";
186,187c186,187
< $imap_options .= "-U $username " if defined $imap_username and $imap_username ne "";
< $imap_options .= "-P $password " if defined $imap_password and $imap_password ne "";
---
> $imap_options .= "-U $imap_username " if defined $imap_username and $imap_username ne "";
> $imap_options .= "-P $imap_password " if defined $imap_password and $imap_password ne "";
314a315,324
>     my $noiselevel;
>     if ($verbose) {
>         $noiselevel = "-v";
>         my $verbosity = $verbose;
>         while ($verbosity >1) {
>             $noiselevel = $noiselevel . "v";
>             $verbosity --;
>         }
>     }
> 
316a327
>       $smtp_plugin = "$smtp_plugin $noiselevel" if $verbose;
345a357
>       $imap_plugin = "$imap_plugin $noiselevel" if $verbose;

Code: Select all

# diff /usr/local/nagios/libexec/check_imap_receive.bak /usr/local/nagios/libexec/check_imap_receive 
109a110,113
> my $debug = 0;
> if ($verbose >2) {
>     $debug = 1;
> }
123c127
<               $imap = Mail::IMAPClient->new(Socket=>$socket, Debug => 0 );
---
>               $imap = Mail::IMAPClient->new(Socket=>$socket, Debug => $debug);
133c137
<               $imap = Mail::IMAPClient->new(Debug => 0 );
---
>               $imap = Mail::IMAPClient->new(Debug => $debug);
141c145
<               $imap = Mail::IMAPClient->new(Debug => 0 );
---
>               $imap = Mail::IMAPClient->new(Debug => $debug);
Interestingly, with the debugging available, I saw that the new server couldn't resolve "localhost" using "host localhost" ,though "ping localhost" worked. This wasn't helping with the IMAP connectivity to the local host! I found absolutely no configuration issues, so did this to fix it: -

Code: Select all

# yum -y install bind && \
chkconfig named on && \
service named start && \
(
  echo 'domain our.domain'
  echo 'search our.domain'
  echo 'nameserver 127.0.0.1'
) >/etc/resolv.conf
Anyway, problem solved ;)
Locked