[Solved] Nagios not sending alerts

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

[Solved] Nagios not sending alerts

Post 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
Last edited by jbruyet on Thu Jul 31, 2014 9:53 am, edited 1 time in total.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Nagios not sending alerts

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Nagios not sending alerts

Post 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
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Nagios not sending alerts

Post 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
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Nagios not sending alerts

Post 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
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Nagios not sending alerts

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Nagios not sending alerts

Post by Box293 »

It looks like you need to add the apache user to the nagcmd group:

Code: Select all

usermod -a -G nagcmd apache
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Nagios not sending alerts

Post 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?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Nagios not sending alerts

Post by Box293 »

Try:

Code: Select all

yum -y install mailx
And see if that works (without tweaking commands.cfg).
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Nagios not sending alerts

Post 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
Locked