LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 09-22-2010, 02:37 PM   #1
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 14
Posts: 336

Rep: Reputation: 30
How to test a Nagios email


This is an odd question, but I can't figure out why my nagios emails aren't being sent. In fact, I got my last one three days ago so it *should* be working.

I have everything in contacts.cfg, and the admin page tells me that the following should be sent: Unknown, Warning, Critical, Recovery, Flapping, Downtime

I also have notify-service-by-email and notify-host-by-email.

I have no idea if nagios emails just don't want to be sent or what -- and I'm not even sure if the nagios emails are even trying to be sent.

Here's my contacts.cfg:

Code:
define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user

        email                           areal@email.address      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }
There's nothing in /var/log/nagios besides the mention of that email address in objects.cache, so I have no idea if an email was attempted to be sent. My sendmail queue is empty as well.

Meanwhile, I have some downtime on a service and didn't get notified. Only the web interface is helping me out here. Any ideas why I am not getting email? How can I run a test to see if everything's working okay?

Last edited by punt; 09-22-2010 at 02:40 PM.
 
Old 09-22-2010, 10:37 PM   #2
leejohnli
Member
 
Registered: Sep 2010
Posts: 58

Rep: Reputation: 2
What distro your using on your nagios server? You need to have email client service for your nagios server in order to receive email from your nagios server. Nagios email under yahoo mail will fall on Spam folder.
 
Old 09-22-2010, 10:48 PM   #3
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
- Add the following options to contact section:
Code:
        service_notifications_enabled   1
        host_notifications_enabled      1
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    c,w,r
        host_notification_options       d,u,r
- Try to stop a service
- Open up 2 terminals (I like Terminator): one to tail the /usr/local/nagios/var/nagios.log and one to /var/log/maillog to see what happen.
 
Old 09-25-2010, 10:48 PM   #4
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 14
Posts: 336

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by leejohnli View Post
What distro your using on your nagios server? You need to have email client service for your nagios server in order to receive email from your nagios server. Nagios email under yahoo mail will fall on Spam folder.
Fedora 13.

As I mentioned, I got email a day prior so I don't understand why that would happen. I am not using Yahoo and there's nothing in my spam folder (I check that pretty often).
 
Old 09-25-2010, 11:02 PM   #5
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 14
Posts: 336

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by quanta View Post
- Open up 2 terminals (I like Terminator): one to tail the /usr/local/nagios/var/nagios.log and one to /var/log/maillog to see what happen.

Thanks. I'm reviewing it now. The only thing I see is this, but it happens every 5 minutes at the same exact second so it doesn't look like anything is happening:

Code:
Sep 25 23:57:58 server sendmail[24024]: o8Q3vw5i024024: server.domain.host.com [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
And nagios is finding the problem (I'm staring at the web interface):

Code:
[1285473600] CURRENT SERVICE STATE: hostname;HTTP;CRITICAL;HARD;4;Connection refused
I'm not sure if the error in sendmail is related but that's the only corresponding line item in the mail log.

Here's the Nagios contact descriptor:

Code:
define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user

        email                           anemailaddressthatworkedafewdaysago@gmail.com      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

        service_notifications_enabled   1
        host_notifications_enabled      1
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    c,w,r
        host_notification_options       d,u,r
}

Any ideas?

Last edited by punt; 09-26-2010 at 01:25 AM.
 
Old 09-26-2010, 02:49 AM   #6
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Quote:
Originally Posted by punt View Post
Thanks. I'm reviewing it now. The only thing I see is this, but it happens every 5 minutes at the same exact second so it doesn't look like anything is happening:

Code:
Sep 25 23:57:58 server sendmail[24024]: o8Q3vw5i024024: server.domain.host.com [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
and nothing relate to nagios? Something like this (I configure with Gmail SMTP):
Quote:
Sep 26 13:11:25 SVR040-763 sendmail[30795]: o8Q6BKJs030793: to=<email@domain>, ctladdr=<nagios@xx> (500/505), delay=00:00:05, xdelay=00:00:04, mailer=relay, pri=120607, relay=smtp.gmail.com [74.125.53.109], dsn=2.0.0, stat=Sent (OK 1285481484 l42sm5200474wfa.21)
Did you config sendmail to work? Could you send mail from command line?
 
Old 09-26-2010, 02:56 AM   #7
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 14
Posts: 336

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by quanta View Post
and nothing relate to nagios? Something like this (I configure with Gmail SMTP):

Did you config sendmail to work? Could you send mail from command line?

Yup - nothing is being sent or logged. And I can send mail from the command line and via [al]pine which is what I normally use. I just tested it.

I have no idea where my nagios emails went but they're missing.
 
Old 09-26-2010, 04:56 AM   #8
zahir.ewest
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Rep: Reputation: 0
try giving the server own email address, cos I installed it on my server and it is working fine & great.
Say if your domain hosted is: demo.com then use the email address : user@demo.com and you will be able to get emails from Nagios.
Plz check if this works.If not, plz also check if you have any email server installed on your server on port 25.
 
Old 09-26-2010, 09:46 AM   #9
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 14
Posts: 336

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by zahir.ewest View Post
try giving the server own email address, cos I installed it on my server and it is working fine & great.
Say if your domain hosted is: demo.com then use the email address : user@demo.com and you will be able to get emails from Nagios.
Plz check if this works.If not, plz also check if you have any email server installed on your server on port 25.
Not sure I understand what you mean in your first item #1. Also, as mentioned multiple times, I'm getting emails. Port 25 is fine. There is nothing being logged in sendmail when there's a problem with Nagios.
 
Old 09-26-2010, 11:07 AM   #10
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 14
Posts: 336

Original Poster
Rep: Reputation: 30
More interesting stuff.

I ran this on the command line:
Code:
# /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" myemailaddress@gmail.com
The email went through.

It's only through Nagios that it's not running. There's nothing in the nagios logs either to reflect that it is trying to notify me. The last time I got anything was just a few days ago (Sept 22) where it showed this.

Code:
[1285033873] SERVICE NOTIFICATION: nagiosadmin;localhost;Current Users;OK;notify-service-by-email;USERS OK - 2 users currently logged in
Now it shows this:

Code:
[1285516837] SERVICE ALERT: localhost;vsftpd;CRITICAL;HARD;4;Connection refused
But it doesn't bother to notify me, as you can see.

I figure something's up with my configuration files, but I never changed anything.. I'll go back to the drawing board and try to figure this out.
 
Old 09-26-2010, 03:28 PM   #11
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 14
Posts: 336

Original Poster
Rep: Reputation: 30
hmm, okay, I changed some files and tweaked some items, and I noticed in many cases I wasn't waiting long enough (apparently nagios doesn't send notifications until the third check). I mostly added notificatons_enabled (1) to all of the items that I was most concerned about and it seems to be working now. Thanks for the help
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
send email notifications in nagios LayTech Linux - Newbie 10 07-24-2010 06:34 AM
[SOLVED] Nagios and Postfix Email Notifications cazter2 Linux - Networking 18 11-19-2009 02:31 PM
Nagios Email notifications jackie001 Linux - Newbie 3 11-14-2008 10:58 AM
No email alert from Nagios packets Linux - Software 0 10-18-2005 11:56 AM
Nagios not sending alerts through email lemay_jeff Linux - Networking 2 04-11-2005 10:28 AM


All times are GMT -5. The time now is 03:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration