LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to test a Nagios email (https://www.linuxquestions.org/questions/linux-server-73/how-to-test-a-nagios-email-833849/)

punt 09-22-2010 02:37 PM

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?

leejohnli 09-22-2010 10:37 PM

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.

quanta 09-22-2010 10:48 PM

- 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.

punt 09-25-2010 10:48 PM

Quote:

Originally Posted by leejohnli (Post 4106217)
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).

punt 09-25-2010 11:02 PM

Quote:

Originally Posted by quanta (Post 4106223)
- 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?

quanta 09-26-2010 02:49 AM

Quote:

Originally Posted by punt (Post 4109113)
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?

punt 09-26-2010 02:56 AM

Quote:

Originally Posted by quanta (Post 4109228)
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. :(

zahir.ewest 09-26-2010 04:56 AM

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.

punt 09-26-2010 09:46 AM

Quote:

Originally Posted by zahir.ewest (Post 4109306)
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.

punt 09-26-2010 11:07 AM

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.

punt 09-26-2010 03:28 PM

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 ;)


All times are GMT -5. The time now is 07:16 AM.