In this chapter we will take a deeper look at the notification function in op5 Monitor. We will look at how theIn the op5 Monitor user manual we describe some of the basics with notifications. Let us take a closer look at how it really works.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
This tells op5 Monitor if notifications are turned on or not in a program-wide basis. Service and host filters
![]()
Does the host or service notification options says that this type of notification is supposed to be sent?
![]()
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?
![]()
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?The notification commands are then using scripts in the same way as the normal check commands does.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: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
A service or host has just entered (or is still in) a problem state. A service or host in a problem state has been acknowledged by a user. The host or service flapping detection has stopped and has there fore left the flapping state. The host or service has left a scheduled downtime. 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: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_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$"The three basic notifications (email, sms and htmlpost notifications) are all using something called notification skins. The notification skins are templates describing how the notification is supposed to look like when it is sent to its receiver.Each folder contains a number of notification skins divided into host and service notification filters.
Example 1 This is a very simple skin. The reason for that is that you can not send too much data with a normal sms.
Example 2 From: op5Monitor
To: #CONTACTEMAIL#
Subject: [op5] #NOTIFICATIONTYPE#: '#SERVICEDESC#' on '#HOSTNAME#' is #SERVICESTATE#Service #NOTIFICATIONTYPE# detected #LASTSERVICESTATECHANGE#.
'#SERVICEDESC#' on host '#HOSTNAME#' has passed the #SERVICESTATE# threshold.Host: #HOSTNAME#
Address: #HOSTADDRESS#
Alias: #HOSTALIAS#
Status: #HOSTSTATE#
Comment: #NOTIFICATIONCOMMENT#Service: #SERVICEDESC#
Status : #SERVICESTATE#
Latency: Check was #SERVICELATENCY# seconds behind schedule
Misc : Check took #SERVICEEXECUTIONTIME# seconds to completeHost actions: #HOSTACTIONURL#
Host notes: #HOSTNOTESURL#Service actions: #SERVICEACTIONURL#
Service notes: #SERVICENOTESURL#The mail notifications can contain a lot more data and there we add a lot more to the mail skin file.That text is called keywords.The keywords will be replaced with the value of a command line argument looking like this:So a command line argument like the one above will generate a keyword with the name FOO having the value BAR.
Note: If a notification macro, or other value sent to a corresponding keyword, is missing in the notification command it will not stop the notification from being sent. It is only the replacement that will be missing.Sometimes the default notification skins needs to be changed. This shall not be done in the default folders.
1
2
3
4 Make the changes you like to do and the new skins will be used at directly after you have saved the changes.Many of the modern mobile phones are only giving you one tiny signal when a sms arrives. If you are on duty during the night you might not wake up or if you are in a very noisy environment it might take some time for you to notice the arrived sms. There for we have included a dial up notification in op5 Monitor.
Table 3
The notify_dial.pl script is called with the following command line: notify_dial.pl is shutting down smsd notify_dial.pl tries to call the <mobilephonenumber>If the line is busy or no one answer the call in 45 seconds notify_dial.pl will hang up and try again two more times before it quits. The user answer the call and notify_dial.pl hangs up. notify_dial.pl is starting up smsd again and the execution is over.
1
2 Click Commands.
3 Add a new command with the following settings:
command_name notify_by_dial
command_line $USER3$/notify/notify_dial.pl "$CONTACTPAGER$"
4 Click Apply.
5 Click Save.
1
3 On the contact set Pager to a phone number on the form like this (without the leading '+'-sign ):
46705123123
4
5 Click Apply.
6 Click Save.
Note: Make sure the contact is a member of the contact_group is associated with the correct objects.op5 Monitor is shipped with the possibility to send notifications as SNMP traps. To start use the SNMP notifications you need to
1
2 Click Commands.
3 Add the following new commands with the following settings:
command_name host_notify_by_snmp
command_line $USER3$/notify/notify_by_snmp.pl -H snmp.trap.host -C SNMPCOMMUNITY -t nHostNotify "NOTIFICATIONTYPE=$NOTIFICATIONTYPE$" "NOTIFICATIONNUMBER=$NOTIFICATIONNUMBER$" "HOSTACKAUTHOR=$HOSTACKAUTHOR$" "HOSTACKCOMMENT=$HOSTACKCOMMENT$" "HOSTNAME=$HOSTNAME$" "HOSTSTATEID=$HOSTSTATEID$" "HOSTSTATETYPE=$HOSTSTATETYPE$" "HOSTATTEMPT=$HOSTATTEMPT$" "HOSTDURATIONSEC=$HOSTDURATIONSEC$" "HOSTGROUPNAME=$HOSTGROUPNAME$" "LASTHOSTCHECK=$LASTHOSTCHECK$" "LASTHOSTSTATECHANGE=$LASTHOSTSTATECHANGE$" "HOSTOUTPUT=$HOSTOUTPUT$"
command_name service_notify_by_snmp
command_line $USER3$/notify/notify_by_snmp.pl -H snmp.trap.host -C SNMPCOMMUNITY -t nSvcNotify "NOTIFICATIONTYPE=$NOTIFICATIONTYPE$" "NOTIFICATIONNUMBER=$NOTIFICATIONNUMBER$" "SERVICEACKAUTHOR=$SERVICEACKAUTHOR$" "SERVICEACKCOMMENT=$SERVICEACKCOMMENT$" "HOSTNAME=$HOSTNAME$" "HOSTSTATEID=$HOSTSTATEID$" "SERVICEDESCRIPTION=$SERVICEDESCRIPTION$" "SERVICESTATEID=$SERVICESTATEID$" "SERVICEATTEMPT=$SERVICEATTEMPT$" "SERVICEDURATIONSEC=$SERVICEDURATIONSEC$" "SERVICEGROUPNAME=$SERVICEGROUPNAME$" "LASTSERVICECHECK=$LASTSERVICECHECK$" "LASTSERVICESTATECHANGE=$LASTSERVICESTATECHANGE$" "SERVICEOUTPUT=$SERVICEOUTPUT$"
Change the following to their correct value, in both commands:
snmp.trap.host
SNMPCOMMUNITY
4 Click Apply.
5 Click Save.
1
3
4
5 Click Apply.
6 Click Save.
Note: Make sure the contact is a member of the contact_group is associated with the correct objects.