Nagios server provides the ability to notify administrators when problems develop. The key to working with Nagios on notifications is to avoid the false alarms that can be very frustrating to those who have to come in and fix the reported problems.
Notification is triggered when the max_check_attempts parameter has been reached and a hard state has occurred. In other words, it is confirmed that the machine has moved from a functioning state to a broken state. So here is also a key to preventing false alarms, move the max_check_attempts for a service or host to a higher number so that it must check a number of times before it notifies administrators. Here is an example that requires 10 attempts.
Until the max_check_attempts has been reached, Nagios still considers this a soft state. In other words, it is waiting for a state change.
Notifications can be turned on or off by editing the nagios.cfg file, one indicating that it is on.
Notifications are sent for host objects for d(down), u(unreachable), r(recovered), f(flapping-up then down state) and now with Nagios 3 s(start of planned maintenance). Notifications are sent for service objects for c(critical), w(warning), u(unknown), r(recovered), f(flapping) and s(start planned maintenance). These options can be entered into the options line to select those options that you want notifications for.
If you set notifications to n(none) it will not send notifications.
The notification_period parameter allows you to set when these notifications should occur.
The notification_interval is an parameter that you can adjust so that you will be able to determine how often you will be notified of a situation.
If you only wanted one notification you can set this parameter to “0”.
Who will be notified is set by the contact information. For example if the contact was all admins it would be set by:
You can define who those admins are by adding contacts and then adding them to the members of the contact grouop.
alias Nagios Administrators
members nagiosadmin ,fred
Nagios 3: Mail Not Sent
One of the major reasons that mail may not be sent when you have a Nagios box set up is that tcp_wrappers could be stopping the ability of the localhost to send email. Edit the /etc/hosts.allow so that it has this line:
That will allow the localhost to send mail to the Nagios administrators.
If you wanted to check to see if you can send mail use this procedure. As a user run the mail command:
Then enter a subject and hit enter. Once that is done you can enter the text for the email and then select Ctrl+d twice to send the email. That will send mail using Sendmail(CentOS) to the email address you specified. You can check your logs and you should see somethign like this indicating the mail was sent.
Mar 27 06:52:45 nagios sendmail: n2RCqjn3024474: to=user@some_email.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30045, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (n2RCqjDf024475 Message accepted for delivery)