Nagios email alerts

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:

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 ]

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]#

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

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

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.

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

still experiencing the same problem

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.

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 [email protected], 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:

You first need to find out if your linux box can run the mail command. Run it by hand.
mail [email protected]
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.

This is what i did,
/usr/bin/printf ā€œOUTPUTā€ | /bin/mail -s ā€˜HOSTALIAS/SERVICEDESC is SERVICESTATEā€™ [email protected]
No error message was received and no email has arrived.

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.

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

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.

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.

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: