This was done with the authorized written permission of nagios.com
There's been a lot of questions as to exactly how notifications work.
This will attempt to explain exactly when and how host and service
notifications are sent out, as well as who receives them.
When Do Notifications Occur?
The decision to send out notifications is made in the service check
and host check logic. The calculations for whether a notification is
to be sent are only triggered when processing a host or service check
corresponding to that notification; they are not triggered simply
because the has passed since a previous
notification was sent. Host and service notifications occur in the
following instances.
- When a hard state change occurs.
- When a host or service remains in a hard non-OK state and the time specified by the option in the host or service definition has passed since the last notification was sent
out (for that specified host or service).
Who Gets Notified?
Each host and service definition has a option that
specifies what contact groups receive notifications for that
particular host or service. Contact groups can contain one or more
individual contacts.
When Nagios sends out a host or service notification, it will notify
each contact that is a member of any contact groups specified in the
option of the service definition. Nagios realizes that
a contact may be a member of more than one contact group, so it
removes duplicate contact notifications before it does anything.
What Filters Must Be Passed In Order For Notifications To Be Sent?
Just because there is a need to send out a host or service
notification doesn't mean that any contacts are going to get notified.
There are several filters that potential notifications must pass
before they are deemed worthy enough to be sent out. Even then,
specific contacts may not be notified if their notification filters do
not allow for the notification to be sent to them. Let's go into the
filters that have to be passed in more detail.
Program-Wide Filter
The first filter that notifications must pass is a test of whether or
not notifications are enabled on a program-wide basis. This is
initially determined by the enable_notifications directive in the main
config file, but may be changed during runtime from the web interface.
If notifications are disabled on a program-wide basis, no host or
service notifications can be sent out - period. If they are enabled on
a program-wide basis, there are still other tests that must be passed.
Notification Methods
You can have Nagios notify you of problems and recoveries pretty much
anyway you want: pager, cellphone, email, instant message, audio
alert, electric shocker, etc. How notifications are sent depend on the
notification commands that are defined in your object definition
files. 1
Read More
1Source:Nagios Notification
This was done with the authorized written permission of nagios.com
After installing alsa by using the command
sudo apt-get install alsa alsa-base alsa-utils
after that we go to configure Nagios Core to use aplay as command-line
audio file player for the ALSA sound card driver.
> $: cd /usr/local/nagios/etc $: sudo nano commands.cfg
adding the following lines
define command{ command_name play_siren command_line /bin/bash
> /usr/local/nagios/etc/objects/play_siren.sh }
create a script to run the sound alarm
> $: cd objects $: sudo nano play_siren.sh
with those lines
> #!/bin/bash /usr/bin/aplay -q /usr/share/nagios/etc/objects/alarm.wav
give to it the permissions and create a log
> $: sudo chown nagios.nagios play_siren.sh $: sudo chmod a+x
play_siren.sh
modify the file contact.cfg to say to nagios of using the sound alarm
> $: sudo nano templates.cfg:
modify the
define contact{
name generic-contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email,play_siren
host_notification_commands notify-host-by-email,play_siren
register 0
}
2
2Source:ideasnet.wordpress.com
Extra References:
custom checks and notifications nagios