Nagios email alerts


#1

Hello,
Is it possible to send a test email to the users of nagios?
My email alerts have suddenly stopped coming even though all the configs are correct :frowning:


#2

check your /var/mail/nagios file
ls -la /var/mail
is nagios file 0 bytes? If not, then your mail has stopped outputting.
/etc/rc.d/init.d/sendmail status
/etc/rc.d/init.d/sendmail restart

Or, send a test.
view misccommands.cfg
define command{
command_name notify-by-email
command_line /usr/bin/printf “%b” “***** Nagios ***\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /bin/mail -s " $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}
So just reproduce a test by substituting values for all the $ stuff. or else you will get just what it says now. i.e. $HOSTALIAS$ etc. change it to hostaliastest etc.

Edited Thu Oct 13 2005, 09:19AM ]


#3

Sir,
The nagios file is not 0 bytes. It is about 121720 bytes.

[root@netmon root]# /etc/rc.d/init.d/sendmail status
sendmail (pid 24507 1678 1669) is running…
[root@netmon root]# /etc/rc.d/init.d/sendmail restart
Shutting down sendmail: OK ]
Shutting down sm-client: OK ]
Starting sendmail: OK ]
Starting sm-client: OK ]
[root@netmon root]#


#4

If after the restart it’s still not working, then delete all the entries in the file.
vi /var/mail/nagios
remove all lines in the file and then save it.
Or simply delete the file entirely and then touch a new one.
Make sure you check the permissions on the file BEFORE you delete it, and then make changes to it after you touch a new file.
ls -la /var/mail/nagios
rm /var/mail/nagios
touch /var/mail/nagios
chmod 660 /var/mail/nagios
chown nagios.mail /var/mail/nagios


#5

Sir,
How can i find out which email server is nagios pointing to, to send out the emails.
Thanks


#6

ps -ef|grep mail
mine says that it’s sendmail that is running.
nagios doesn’t point to anything. All it does is run the command as defined in misccommands.cfg which is the “mail” command.
Type
man mail
for more info on mail command.


#7

Sir, does nagios send an email or does it relay it. If it is relaying the alerts then probably my Mail Foundry is blocking it.
Thanks


#8

still experiencing the same problem


#9

nagios executes the “mail” command. See
man mail for more info on the mail command.
I am using sendmail as the mail transport.
I had one time a mail message that locked up the outgoing mail, so the /var/mail/nagios file just filled up. I deleted it, then touched a new one, and problem was gone.
You may have a firewall turned on, so turn it off, till you figure out how to get by the firewall on the nagios box. It’s most likely SeLinux firewall.


#10

Hello. I did all possible tries for getting email alerts. Turned off the firewall. Checked the /var/mail/nagios, it is 0bytes. The mails are going somewhere but they are not getting delivered.
I also changed an email address to himohit@yahoo.com, which is my pesonal email address still the email did not reach it. I also tried, as someone suggested, by changing the Smart_host in sendmail.mc file to smtp.ispname.com, but still negative results.
Do i need to change my HOSTNAME in /etc/sysconfig/network. Right now the HOSTNAME is localhost.localdomain
Will changing it to nagios.domainname.com help?
Thanks :slight_smile:


#11

You first need to find out if your linux box can run the mail command. Run it by hand.
mail himohit@yahoo.com
fill in the subject, enter some body text, hit ctrl-d
you should get an email.
if that works, then follow the docs to enable nagios notifications.


#12

This is what i did,
/usr/bin/printf “OUTPUT” | /bin/mail -s ‘HOSTALIAS/SERVICEDESC is SERVICESTATE’ himohit@yahoo.com
No error message was received and no email has arrived.


#13

Then problem is not in nagios but with your mail setup. I’m not very good with sendmail, but that’s all I did was install sendmail and made no changes to it at all.


#14

rpm -qf /bin/mail
mailx-8.1.1-33
rpm -qf /usr/sbin/sendmail
sendmail-8.13.1-2


#15

Nop, the email did not go through. So it is probably not the nagios configs which are a problem. Can you suggest me anything Sir.


#16

Do you have a DNS on your network. Did you install the rpms for sendmail and mail. Unininstall sendmail and mail and reinstall with defaults.


#17

Yes there is a seperate DNS server running on my network. I am going to try and reinstall sendmail and mail again.
Thanks :slight_smile: