skip to main content
Notifications : How does notifications work
   
How does notifications work?
 
Notification filters
Notification commands
Notification macros
Notification e-mail sender
In the op5 Monitor user manual we describe some of the basics with notifications. Let us take a closer look at how it really works.
Notification filters
When a notification is about to be sent it has to go through a number of filters before op5 Monitor can determine whether a notification really is suppose to be sent or not.
Table 1 Notification filters
Filter
Description
Program-wide
This tells op5 Monitor if notifications are turned on or not in a program-wide basis.
Service and host filters
Is the host or service in scheduled downtime or not?
Is the host or service in a flapping state?
Does the host or service notification options says that this type of notification is supposed to be sent?
Are we in the right time period for notifications at the moment?
Have we already sent a notification about this alert?
Has the host or service remained in the same non-OK state that it was when the last notification went out?
Contact filters
Does the contacts notifications options says that this type of notification is supposed to be sent?
Are we in the right time period for notifications at the moment, according to the notification time period set on the contact?
 
Notification commands
How the notifications are sent is defined in either one of the two files below:
checkcomands.cfg
misccommands.cfg
The commands are divided into
host notification commands
service notification commands
The notification commands are then using scripts in the same way as the normal check commands does.
All default scripts shipped with op5 Monitor is located in:
/opt/monitor/op5/notify
Notification macros
Many of the arguments sent to the notification commands are macros. The macros are a sort of variables containing a, in most cases, program-wide value. You can read more about macros in the Nagios manual:
http://nagios.sourceforge.net/docs/3_0/macros.html
One of the most important macro used with notifications is:
$NOTIFICATIONTYPE$
This macro tells you what type of notification that is supposed to be sent. The $NOTIFICATIONTYPE$ macro can have one of the following values.
Table 2 Notification types
Notification type
Description
PROBLEM
A service or host has just entered (or is still in) a problem state.
RECOVERY
A service or host has recovered from a problem state.
ACKNOWLEDGEMENT
A service or host in a problem state has been acknowledged by a user.
FLAPPINGSTART
The host or service has entered a flapping state.
FLAPPINGSTOP
The host or service has left a flapping state.
FLAPPINGDISABLED
The host or service flapping detection has stopped and has there fore left the flapping state.
DOWNTIMESTART
The host or service has entered a scheduled downtime.
DOWNTIMESTOP
The host or service has left a scheduled downtime.
DOWNTIMECANCELLED
The scheduled downtime for a host or service has been cancelled.
The list of macros described in the Nagios manual is very useful when you are working with new notification commands and scripts. That list can be found here:
http://nagios.sourceforge.net/docs/3_0/macrolist.html
Notification e-mail sender
Notifications are by default sent from the e-mail address ”op5monitor” without any domain. The MTA adds the local domain name, witch by default is “@localhost.localdomain”.
To change the e-mail address that notification are sent from use the --from-mail argument for the notification command.
To change the sender e-mail address from op5monitor@localhost.localdomain to op5notification@mycompany.com simply go to the check command for the host-notify and add “--from-email op5notification@mycompany.com” without the “-signs.
command_name=host-notify
command_line=$USER3$/notify/poller_notify_send.pl --from-email op5notification@mycompany.com -c "$CONTACTNAME$" -h "$HOSTNAME$" -f "$NOTIFICATIONTYPE$" -m "$CONTACTEMAIL$" -p "$CONTACTPAGER$" "HOSTALIAS=$HOSTALIAS$" "HOSTADDRESS=$HOSTADDRESS$" "HOSTSTATE=$HOSTSTATE$" "HOSTSTATEID=$HOSTSTATEID$" "HOSTSTATETYPE=$HOSTSTATETYPE$" "HOSTATTEMPT=$HOSTATTEMPT$" "HOSTLATENCY=$HOSTLATENCY$" "HOSTEXECUTIONTIME=$HOSTEXECUTIONTIME$" "HOSTDURATION=$HOSTDURATION$" "HOSTDURATIONSEC=$HOSTDURATIONSEC$" "HOSTDOWNTIME=$HOSTDOWNTIME$" "HOSTPERCENTCHANGE=$HOSTPERCENTCHANGE$" "HOSTGROUPNAME=$HOSTGROUPNAME$" "HOSTGROUPALIAS=$HOSTGROUPALIAS$" "LASTHOSTCHECK=$LASTHOSTCHECK$" "LASTHOSTSTATECHANGE=$LASTHOSTSTATECHANGE$" "LASTHOSTUP=$LASTHOSTUP$" "LASTHOSTDOWN=$LASTHOSTDOWN$" "LASTHOSTUNREACHABLE=$LASTHOSTUNREACHABLE$" "HOSTOUTPUT=$HOSTOUTPUT$" "HOSTPERFDATA=$HOSTPERFDATA$" "HOSTACKAUTHOR=$HOSTACKAUTHOR$" "HOSTACKCOMMENT=$HOSTACKCOMMENT$" "NOTIFICATIONNUMBER=$NOTIFICATIONNUMBER$" "CONTACTALIAS=$CONTACTALIAS$" "DATETIME=$DATETIME$" "SHORTDATETIME=$SHORTDATETIME$" "DATE=$DATE$" "TIME=$TIME$" "TIMET=$TIMET$" "HOSTACTIONURL=$HOSTACTIONURL$" "HOSTNOTESURL=$HOSTNOTESURL$" "ADMINPAGER=$ADMINPAGER$" "ADMINEMAIL=$ADMINEMAIL$" "NOTIFICATIONCOMMENT=$NOTIFICATIONCOMMENT$"
This has to be done for the command “service-notify” as well.