Sometimes it may be necessary to create and run custom notification methods depending on your environment and requirements in accordance with custom SLA’s, contracts, etc. In Opsview this is very simple to setup.
Firstly, the directory location for the notification scripts is located at /usr/local/nagios/libexec/notifications. In here you will see the scripts already on Opsview, plus any other additional notifications already created:
In this example, we are going to be using “notify_by_email” as our script.
After logging into the Opsview web interface, we will now need to proceed to create the new notification first are foremost. To do this, we will need to navigate to “SETTINGS > NOTIFICATION METHODS”.
In the top corner, there will be the “addition” sign. 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 called when the notification method is engaged. Click “submit changes”, and our new notification method “Opsview Demo Notification” is now created.
Now we need to add this notification to a contact, so that the contact will be notified when the parameters for the notification to be initiated, have been satisfied. To do this, we need to navigate to “Settings > Contacts” and click on the contact we wish to modify, in this case “smarsh”.
Once on the contact profile, click the button “Submit and edit notification profiles” - make sure that the password boxes are both empty, as some browsers may auto populate one of these fields.
Once loaded, we can now edit which notifications are attached to that contact, and as we need to, add our own custom notification.
As you can see, we have a check box under the “Notify by..” section, and in this section we can see our new notification “Opsview Demo Notification”. Simply toggle this box, 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 do we want this notification to be sent for - in this case, only the “premium, monitoring servers and ESX servers”.
We can also configure when we want this notification to be called, and for what alerts. We may only want to know when a critical alert happens or when a box is down, not when a service is flapping (i.e. an engineer on call over night).
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. And the notification will only be engaged during “nonworkhours”, as specified in “SETTINGS > TIME PERIODS” (so the notification will only do the action during 6pm-8am, for example).
Finally, submit the changes and go to “SETTINGS > APPLY CHANGES” to apply our new notification to our user(s).