[Solved] Nagios not sending alerts
[Solved] Nagios not sending alerts
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
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.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios not sending alerts
Let's look at a few logs.
Firstly, sending a test alert can be quickly done this way:
Firstly, there is this one:
Send a test notification and see what appears here.
Also, does anything appear here:
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
Firstly, there is this one:
Code: Select all
tail -f /var/log/messagesAlso, does anything appear here:
Code: Select all
tail -f /usr/local/nagios/var/nagios.logAs of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Nagios not sending alerts
Well, now I have something to look into:
Thanks,
Joe B
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 cameJoe B
Re: Nagios not sending alerts
The permissions look good to me:
Thanks,
Joe B
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]#
Joe B
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Nagios not sending alerts
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/groupNagios-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.
Re: Nagios not sending alerts
Hi sreinhardt, here's what I'm seeing in /etc/passwd and /etc/group:
Thanks,
Joe B
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]#
Joe B
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios not sending alerts
It looks like you need to add the apache user to the nagcmd group:
Code: Select all
usermod -a -G nagcmd apacheAs of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Nagios not sending alerts
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:
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:
I did find a postfix under /usr/sbin but I'm not sure if I should use that command or something else. Suggestions?
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 pipeCode: 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]# - Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios not sending alerts
Try:
And see if that works (without tweaking commands.cfg).
Code: Select all
yum -y install mailxAs of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Nagios not sending alerts
Bummer:
If I were to tweak the commands.cfg file my only question is which postfix link/executable do I use?
Thanks,
Joe B
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]#Thanks,
Joe B