Sometimes it may be necessary to create and run custom notification methods depending on your environment and requirements in accordance with custom SLAs, contracts, etc. In Opsview Monitor this is very simple to do.
The directory location for the notification scripts is _/opt/opsview/monitoringscripts/notifications_. In here you will see the scripts already in Opsview Monitor, plus any other additional notifications already created:
In this example, we are going to assume that _notify_by_email_ is the name of our new notification script. Note that in a fresh installation of Opsview Monitor, an e-mail notification method is already provided.
After logging into the Opsview Monitor User Interface, we will first need to create the new [Notification Method](🔗). To do this, we will need to navigate to _Configuration > Notification Methods_.
In the top corner, there will be the _Add New_ Button. Click this to load the new _New notification method_ window. As per the image below, we will need to populate this box with the appropriate information:
As you can see, the name of the module we created should be added to the _command_ field, as this is the script that will be executed when the Notification Method is called. Click _Submit Changes_, and our new Notification Method _Opsview Demo Notification_ is now created.
Now we need to create a [Notification Profile](🔗) for a User, so that they will be notified using this method. To do this, navigate to _Settings > Users And Roles_ and click on the User you wish to modify. Once on the User profile, click the button _Notification Profiles_ then _Add New_.
Once loaded, we can now edit which notifications are sent to that User and using which Notification Method.
As you can see, we have a drop-down menu in the _Host Groups_ section, and in this section, we can see our new notification _Opsview Demo Notification_. Simply select this option, and our new notification is added to this user. This can be done for all applicable users. We can also configure further information on this page, such as for which Host Groups we want this notification to be sent for.
We can also configure when we want notifications to be sent, and for what alerts. We may only want to know when a critical alert occurs or when a Host is down, but not when a service is flapping. A common use case for this sort of configuration is when defining an On-Call Engineer notification profile.
So as above, we have configured it only to alert us on warning/critical alerts on services, and for only on Hosts which are down or unreachable. The notifications will only be engaged during "nonwork hours", as specified in _CONFIGURATION > TIME PERIODS_ (so the notification will only do the action during 6pm-8am, for example).
Finally, submit the changes and go to _CONFIGURATION > APPLY CHANGES_ to apply the new notification settings.