Users with ePN should use the ePN versions of the scripts. Look for check_smtp_send_epn, check_imap_receive_epn, and check_email_delivery_epn in the download package. Substitute these epn versions wherever you see the regular script names in the examples. No other change is needed.
check_email_delivery runs other plugins to create the email loop. If any of those exits with a CRITICAL status, then check_email_delivery will also exit with CRITICAL. If all return OK or WARNING, then check_email_delivery continues the check and uses threshold options to decide whether to return OK or WARNING.
As of version 0.5, any plugins can be used to create the loop by using the --plugin option. The possibilities are pretty exciting. For example, you can check the function of an email-to-ftp gateway: use check_smtp_send to send the email, and then use an ftp plugin to check that the file is accessible by ftp. You can also use other plugins.
The new --token option automatically creates random numbers or strings to be passed to all specified plugins in order to link their operation, so that you can send an email with a random string like "aardvark 23429" using check_smtp_send and then look for this specific string to be found in the mailbox using check_imap_receive.
As of version 0.6, there is an --alert option that you can use in conjunction with the --plugin option. This new --alert option is useful if your delivery loop involves more than one server and you happen to only be interested in the status of just one of the servers.
How do you send attachments or other special messages? Currently there is no built-in way but you can use the --stdin option to send a prepared message (with attachments). So send yourself the message you want to use for testing, then use your mail client's "view raw message" feature, copy & paste the raw message body to a text file on your nagios server. Configure check_smtp_send like this: cat saved_message.txt | check_smtp_send --stdin [other options here].
# politely disconnect from the SMTP server. sub quit { my $me = shift; $me->_command("QUIT"); my ($num, $txt) = $me->_response(); if(not $num == 221){ croak "An error occurred disconnecting from the mail server: $num $txt\n"; } }Should be:
# politely disconnect from the SMTP server. sub quit { my $me = shift; $me->_command("QUIT"); my ($num, $txt) = $me->_response(); my $numnum = $num + 0; # force it to be numeric -jb $txt = "" unless $txt; if(not $numnum == 221){ croak "An error occurred disconnecting from the mail server: $num $txt\n"; } }
Problem: The email, at last, is sent, but the plugin returns an UNKNOW STATE to Nagios. Shell execution returns that:
./check_smtp_send -H smtp.gmail.com --mailfrom mymail@gmail.com --mailto mymail@test.com -U myuser@gmail.com -P mypassword --header "Subject: Nagios Test" -w 5 -c 120 --tls --ssl Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/site_perl/5.8.8/Net/SMTP/TLS.pm line 140, line 7. Use of uninitialized value in numeric eq (==) at /usr/lib/perl5/site_perl/5.8.8/Net/SMTP/TLS.pm line 396, line 7. Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.8/Net/SMTP/TLS.pm line 397, line 7. Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.8/Net/SMTP/TLS.pm line 397, line 7. An error occurred disconnecting from the mail server: at ./check_smtp_send line 203
I've got all needed Perl modules well installed and the plugin works well through other smtp servers without ssl. Solution: This appears to be a malfunction of the gmail servers. Apparently once the smtp client sends the "quit" command, gmail disconnects immediately instead of sending a successful quit response (don't ask me why that's part of the protocol in the first place). The Net::SMTP::TLS module then has a problem because it's looking for this response and it's not there, which is what causes those warnings you see on the console. On my system I fixed it by editing /usr/lib/perl5/site_perl/5.8.8/Net/SMTP/TLS.pm Line 139: add || "" to the end of the line immediately before the semicolon. So the revised line looks like this:
my $line = $me->{sock}->getline() || ""; Line 395: add || (221,"") to the end of the line immediately before the semicolon. So the revised line looks like this: my ($num, $txt) = $me->_response() || (221,"");
After doing that, the script runs ok.
Your Nagios is probably compiled with an embedded Perl interpreter.
Try using the embedded Perl versions of the plugins; they are included in the archive you downloaded from the check_email_delivery website and are drop-in replacements for the regular Perl versions.
Regular Perl | Embedded Perl |
---|---|
check_email_delivery | check_email_delivery_epn |
check_smtp_send | check_smtp_send_epn |
check_imap_receive | check_imap_receive_epn |
If that doesn't solve your problem, try calling Perl with the script instead of the script directly. So change $LIBEXEC$/check_email_delivery to perl $LIBEXEC$/check_email_delivery.
If that doesn't solve your problem, you can try recompiling your Nagios without the embedded Perl interpreter. You can then use the regular versions of the plugins.
Need help configuring the plugin? Send your question by email: jonathan@buhacoff.net
Thousands of users worldwide. Listed in Nagios Exchange. If you find this software useful, please donate.