Page 1 of 2

[Solved] Nagios not sending alerts

Posted: Fri Jul 25, 2014 4:56 pm
by jbruyet
Hey all, I have Nagios 4.0.6 running on CentOS 6.5. Everything is running smoothly so I decided it was time to implement alerting. Per some instructions I was following I uninstalled sendmail and installed postfix. These are my Nagios alerting configuration settings thus far:

nagios.cfg: notifications_enabled=1
Contact template: notifications_enabled=1
Define host has correct contact_groups
Define host has 15 minute notification_interval

I disabled the NIC on one of my servers for about 23 minutes but I never received an alert. I thought that maybe I messed up the postfix install but I ran the following test and it sent a text message to my phone:

echo "Wuzzup Guy" | mail -s "test email" MyPhone#@vtext.com

I looked at /usr/local/nagios/var/nagios.log and I couldn't find any errors.

So, I think the problem is in Nagios but I don't know where to look. Any ideas, suggestions or recommendations?

Thanks,

Joe B

Re: Nagios not sending alerts

Posted: Sun Jul 27, 2014 6:49 pm
by Box293
Let's look at a few logs.

Firstly, sending a test alert can be quickly done this way:
  • In the web interface click on a host
    Under host commands click "Send custom host notification"
    Add a comment and click Commit
So you can watch a couple of logs.

Firstly, there is this one:

Code: Select all

tail -f /var/log/messages
Send a test notification and see what appears here.

Also, does anything appear here:

Code: Select all

tail -f /usr/local/nagios/var/nagios.log

Re: Nagios not sending alerts

Posted: Mon Jul 28, 2014 2:07 pm
by jbruyet
Well, now I have something to look into:

Code: Select all

Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!

The permissions on the external command file and/or directory may be incorrect. Read the FAQs on how to setup proper permissions.

An error occurred while attempting to commit your command for processing.

Return from whence you came
Thanks,

Joe B

Re: Nagios not sending alerts

Posted: Mon Jul 28, 2014 2:10 pm
by jbruyet
The permissions look good to me:

Code: Select all

[root@Nagios rw]# ls -l
total 0
prw-rw---- 1 nagios nagcmd 0 Jul 25 14:16 nagios.cmd
srw-rw---- 1 nagios nagcmd 0 Jul 25 14:16 nagios.qh
[root@Nagios rw]#

Thanks,

Joe B

Re: Nagios not sending alerts

Posted: Mon Jul 28, 2014 3:10 pm
by sreinhardt
Let's check your groups, the cgi's will actually get run as the apache\httpd user, so permissions look good but there's more to it.

Code: Select all

grep -Ri 'nag' /etc/passwd
grep -Ri 'nag' /etc/group

Re: Nagios not sending alerts

Posted: Mon Jul 28, 2014 4:53 pm
by jbruyet
Hi sreinhardt, here's what I'm seeing in /etc/passwd and /etc/group:

Code: Select all

[root@Nagios jobee]# grep -Ri 'nag' /etc/passwd
nagios:x:501:501::/home/nagios:/bin/bash
[root@Nagios jobee]# grep -Ri 'nag' /etc/group
nagios:x:501:
nagcmd:x:502:nagios
[root@Nagios jobee]#
Thanks,

Joe B

Re: Nagios not sending alerts

Posted: Mon Jul 28, 2014 8:12 pm
by Box293
It looks like you need to add the apache user to the nagcmd group:

Code: Select all

usermod -a -G nagcmd apache

Re: Nagios not sending alerts

Posted: Tue Jul 29, 2014 1:48 pm
by jbruyet
Thanks Box293, I'm no longer getting the error message. However, I have discovered that I need to make some tweaks in the commands.cfg file. Here's something from /var/log/messages:

Code: Select all

Jul 29 11:28:36 Nagios nagios: wproc:   host=srv-Dictum2; service=(none); contact=JobeePhone
Jul 29 11:28:36 Nagios nagios: wproc:   early_timeout=0; exited_ok=1; wait_status=32512; error_code=0;
Jul 29 11:28:36 Nagios nagios: wproc:   stderr line 01: /bin/sh: /usr/bin/mail: No such file or directory
Jul 29 11:28:36 Nagios nagios: wproc:   stderr line 02: /usr/bin/printf: write error: Broken pipe
I need to add a postfix command so Nagios knows how to send an email. I looked under /usr/bin for postfix and didn't quite find what I was looking for:

Code: Select all

lrwxrwxrwx. 1 root root         31 May  9 16:13 mailq.postfix -> ../../usr/sbin/sendmail.postfix
lrwxrwxrwx. 1 root root         31 May  9 16:13 newaliases.postfix -> ../../usr/sbin/sendmail.postfix
-rwxr-xr-x. 1 root root        262 Feb 20 02:07 rmail.postfix
[root@Nagios bin]# 
I did find a postfix under /usr/sbin but I'm not sure if I should use that command or something else. Suggestions?

Re: Nagios not sending alerts

Posted: Tue Jul 29, 2014 3:58 pm
by Box293
Try:

Code: Select all

yum -y install mailx
And see if that works (without tweaking commands.cfg).

Re: Nagios not sending alerts

Posted: Tue Jul 29, 2014 4:42 pm
by jbruyet
Bummer:

Code: Select all

updates/primary_db                                                                              | 4.2 MB     00:01
Setting up Install Process
Package mailx-12.4-7.el6.x86_64 already installed and latest version
Nothing to do
[root@Nagios jobee]#
If I were to tweak the commands.cfg file my only question is which postfix link/executable do I use?

Thanks,

Joe B