Welcome to docs.opsview.com

Notification Methods

This provides a list of notification methods that you can use in Opsview.

Opsview ships with multiple notification methods, including:

You can activate as many notification methods as you like.

If there are any contact variables that need to be set, then each contact needs to configure their variables in order for the notification to work (for instance, to use email, each contact has to define their email address).

Name

The name of the notification method. This does not have to be unique, but you are advised to keep it unique for sanity!

Active

You can disable the notification method from being displayed in the contact or notification profile pages.

If you disable the notification method, then all contacts will have this notification method removed.

If there are contacts that still use the notification method, this will get listed when you disable it.

Run On

This option is only shown on systems with slaves configured.

You can specify whether the notification method is run on:

  • Master
  • Slave

If you are using Service Desk Connector, this must be set to Master.

Note: If you select Slave and the host that wants to send a notification is monitored by the master server, then the notification will be sent from the master server.

In the diagram above, the monitoring server for host H2 is the master server M. Host H1's monitoring server is the slave S1 and host H3 is monitored by slave S2. Host H4's monitoring server is slave S3.

This is important to decide because it could be possible that results are lost between the slave and the master in a network failure. However, there may be firewall restrictions to running a notification from a slave.

Note: The advantage of running notifications from a slave is that it is autonomous of the master. However, the slave may not do parent/child suppression if the parent of a host is on a different slave - this is particularly true if you are using a slave cluster. You have to send notifications from the master if you want the full suppression facilities as only the master has a complete view of all your hosts.

Note: If a service is monitored by a slave but the notification method is set to the master, then UNKNOWN states will not be notified on. This is because in a distributed environment, if a slave fails, the master will set the state of all services on that slave into an UNKNOWN state. This filtering means that you will not get lots of notifications for a single issue when a slave has failed.

Note: Notifications that are sent from a slave are logged on the slave, but are not logged on the Opsview master.

Command

This is the script to execute. It is assumed that this script is stored in /usr/local/nagios/libexec/notifications. Add any command arguments as required

Contact Variables

This is a comma separated list of variables that the notification method requires for each contact.

Note: The variables specified will be saved as custom contact variables of the format _{name}. These variables can then be accessed in your notification script by the environment variable NAGIOS__CONTACT{name} (note the double underscore).

Note: EMAIL and PAGER are treated differently and will be saved as email and pager in the Nagios® Core configuration. PAGER is the variable used to hold a mobile phone number. The variables are accessed via NAGIOS_CONTACTEMAIL and NAGIOS_CONTACTPAGER respectively.

Custom Configuration Options

There maybe additional fields based on the notification method

AQL

AQL Username

AQL provide a simple way of transmitting SMS alerts from Opsview. This service works from most countries, all you need is an AQL account.

Sign up for prepaid credits at aql.com with the code 'opsera-1234' to receive discounted rates and 50 free credits.

This is the username for the AQL system. Click on Check Credit to see how many credits you still have from AQL

AQL Password

This is your AQL password.

AQL Proxy Server

AQL's solution requires that the Opsview server has connectivity to AQL over HTTP/80. AQL's messaging servers are:

  • gw1.sms2email.com
  • gw11.sms2email.com
  • gw2.sms2email.com
  • gw22.sms2email.com

These servers are used in a round robin fashion, so your firewall must allow connection to each one. If you use a web proxy server, enter the proxy information in the format:

http://user:password@host:port/

IOS Push Notifications

Use the 'Push Notifications For IOS Mobile' notification method to send push notifications to your iOS device.

More information at our Opsview Mobile page.

IOSPush Username

This is your Opsview systems username, the same one used to log into our main web site.

IOSPush Password

This is your Opsview systems password, the same one used to log into our main web site.

IOS Proxy

If your server needs to route through a proxy, put its full address here, eg. http://example.com:8080

Android Push Notifications

Use the 'Push Notifications For GCM Mobile' notification method to send push notifications to your GCM device.

More information at our Opsview Mobile page.

GCMPush Username

This is your Opsview systems username, the same one used to log into our main web site.

GCMPush Password

This is your Opsview systems password, the same one used to log into our main web site.

GCM Proxy

If your server needs to route through a proxy, put its full address here, eg. http://example.com:8080

PagerDuty

PagerDuty is now available out of the box with Opsview. PagerDuty is a message platform where users can send various messages to PagerDuty, and create rules within the PagerDuty application to dispatch alerts via various methods such as SMS, Email, etc to individuals or groups of users. To use Pagerduty with Opsview, users need to setup an account on pager duty and follow the steps below to activate it on the Opsview system.

  • Activate the method by setting it active from Settings→notification methods.
  • Go to http://www.pagerduty.com and sign up. Please make sure you provide them a valid email address as this where they will try to forward your notifications.
  • Follow pagerduty guide to setup a pagerduty service for opsview.
  • Once you have the key create a contact in Opsview which will use pager duty as the notification method.
  • Provide the Service key in the notification tab of the contact.
  • Click on “Submit and edit notification profile”.
  • When loaded make sure the pagerduty is checked in the notify by options.
  • Submit and reload changes, once the reload finishes Pager Duty should be ready to receive messages.

Note: PagerDuty only works with Nagios notifications, BSM notifications are not currently supported.

VictorOps

VictorOps is available out of the box with Opsview 4.6.1 and later. Like PagerDuty, VictorOps is a message platform where users can send various messages to VictorOps, and create rules within the VictorOps application to dispatch alerts via various methods such as SMS, Email, etc to individuals or groups of users. Users need to setup an account on VictorOps and follow the steps below to activate it on the Opsview system.

  • Activate the method by setting it active from Settings→notification methods.
  • Go to http://www.victorops.com and sign up. Please make sure you provide them a valid email address as this where they will try to forward your notifications.
  • Follow VictorOps guide to get the REST Endpoint URL.
  • Create Teams in VictorOps to get a Routing key for your contacts by clicking Settings, choose the schedule tab and click the Add Team button.
  • Once the team is added scroll down until you see the team name and its schedule and click on Setup Routing link.
  • Once you have the API key and the Routing key create a contact in Opsview which will use VictorOps as the notification method.
  • Provide the API key in the notification method for VictorOps.
  • Provide the Routing key in the notification tab of the contact.
  • Click on “Submit and edit notification profile”.
  • When loaded make sure the VictorOps is checked in the notify by options.
  • Submit and reload changes, once the reload finishes VictorOps should be ready to receive messages.

Note: VictorOps only works with Nagios notifications, BSM notifications are not currently supported.

VictorOps API Key

Enter the VictorOps API Key from the setup above.

Twilio

Twilio is available out of the box with Opsview 4.6.2 and later. Twilio is a messaging platform that allows users to send all alerts from Opsview into Twilio, and create rules that can notify specified users using specified methods - even including voice calls! To configure Twilio integration, users need to setup an account on Twilio and follow the steps below to activate it on the Opsview system.

  • Go to http://www.twilio.com and sign up.
  • Login to Twilio account to get the Account id, Auth token and the Twilio from number.
  • Verify the mobile numbers where notifications are going to be receieved whilst logged in to the Twilio account.
  • Once you have the Account sid, Auth Token and the Twilio from number create a contact in opsview which will use Twilio as the notification method.
  • Activate the method by setting it active from Settings→notification methods.
  • Provide the Account sid, Auth token and Twilio from number in the notification method page for Twilio.
  • Provide the verfied mobile number in the notification tab of the contact.
  • Click on “Submit and edit notification profile”.
  • When loaded make sure the tiwlio is checked in the notify by options.
  • Submit and reload changes, once the reload finishes Twilio should be ready to receive messages.

Twilio Number

Enter the Twilio number from the setup above.

Twilio Account ID

Enter the Twilio account id from the setup above.

Twilio Auth Token

Enter the Twilio auth token from the setup above.

Slack

Slack is available out of the box with Opsview 4.6.2 and later. Slack is a modern day pseudo 'chat room', that alows teams of users to collaborate over the internet. The value-add over a chatroom is that Slack allows 'inbound integrations' from various tools such as Opsview. This means that an 'Operations team' can have a chat room, where alerts from Opsview are sent - meaning they can discuss and view alets in the same forum - as opposed to a standalone email. To configure this integration, users need to setup an account on Slack and follow the steps below to activate it on the Opsview system.

  • Sign up for slack account and it will take you through the basic setup process of creating teams and rooms.
  • Once the setup is finished and you have sent out relevant team and members invite, go into account settings to create a incoming-webhook url for any of the rooms or teams you have created:
  • Click on Integrations on the left hand side, and then click on 'Make your own' which will take you down to the bottom of the screen.

* After clicking 'Make your own', click on the 'Incoming webhooks' button.

  • In the 'Post to Channel' section, select the name of your channel from the drop-down and click 'Add Incoming WebHooks Integration'.

* Make a note of the Webhook URL that is generated under 'Setup Instructions > Webhook URL:' (this will be used for entering the Webhook URL in Opsview later).

  • Now, login to your Opsview system.
  • Navigate to 'Settings > Notification Methods > Slack'.
  • Activate the method by setting it to active.
  • Enter the Webhook url in the relevant box.
  • Enter the room name which begins with a # sign
  • NB: If users want to send notification directly to a Slack username and not a channel, this can be done by prefixing the username with the @ in the channel notification variable.
  • After the above steps are completed you should have a notification method that looks similar to the below:

  • Finally, setup and configure any personal or shared notification profiles to use this new notification method.
  • Submit and reload changes, once the reload finishes Slack should be ready to receive messages.

HipChat

HipChat is available out of the box with Opsview 4.6.2 and later. Like Slack, Hipchat is a modern day pseudo 'chat room', that alows teams of users to collaborate over the internet. The value-add over a chatroom is that Hipchat allows 'inbound integrations' from various tools such as Opsview. This means that an 'Operations team' can have a chat room, where alerts from Opsview are sent - meaning they can discuss and view alets in the same forum - as opposed to a standalone email. To configure this integration, users need to setup an account on HipChat and follow the steps below to activate it on the Opsview system.

  • Create a HipChat account.
  • Create a Room by launching the web app
  • Click on the HipChat Icon
  • Click Rooms>Your_Room_Name>Summary
  • Make a note of the API ID, this is the HipChat Room ID

* Click Tokens on the left hand side

  • Create a new token by entering a value of your choice in the 'Label' field and click the 'Create' button
  • Copy the newly created token e.g. '9ghN32Kiet13VSmnxDovGzy613y8g44bzawaM9h7' this is the Authentication Token

  • Now, go to your Opsview system.
  • Navigate to 'Settings > Notification methods > Hipchat'.
  • Enter the Authentication Token and Room ID as below, and then hit submit changes.

  • Perform a reload: settings → Configuration → Reload
  • You should now be ready to receive notification messages

Customising the Email Template

The email template is written in Template Toolkit and exists in /usr/local/nagios/libexec/notifications/com.opsview.notificationmethods.email.tt.

You can customise this file, but be aware that it will be overwritten as part of any future upgrades.

The patch below can be used to add a URL line to the email:

--- com.opsview.notificationmethods.email.tt.original	2010-09-16 16:05:14.000000000 +0100
+++ com.opsview.notificationmethods.email.tt	2010-09-16 16:06:25.000000000 +0100
@@ -25,6 +25,7 @@
 %]
 Date & Time: [% nagios.longdatetime %]

+URL: http://opsview.example.com/status/service?host=[% nagios.hostname %]
 Additional Information:

 [%

A complete list of Nagios Core macros is available at: http://nagios.sourceforge.net/docs/3_0/macrolist.html

From Opsview 3.15.0, you can also reference some Opsview configuration variables. Currently the following are supported:

Code Description Example output
hostgroup=nagios.hostgroupname; matpath=config.hostgroups.$hostgroup.matpath.replace(”,”, ” > ”); matpath Returns the hierarchy that the host belongs to Opsview > Europe > UK > Monitoring Systems

From Opsview 3.15.0, you can change the default email template used. Set the command as notify_by_email -e email-template-name and Opsview will look for an email template in /usr/local/nagios/libexec/notifications/email-template-name. You can test your email template by running:

/usr/local/nagios/utils/test_notifications hostproblem /usr/local/nagios/libexec/notifications/notify_by_email -t -e email-template-name

This will output the contents of the email.

If you have changed the email template, you will need to redistribute the files to the other slaves. Run: send2slaves -p to send the contents to /usr/local/nagios/libexec to all slaves.

Adding a New Notification Script

You may want to use an existing Nagios Core notification script in Opsview. To add this in:

  • Check the notification script for any dependencies. This may require additional software to be installed on the Opsview master (and slaves)
  • Test the notification script. Opsview provides a way of simulating the environment variables that Nagios Core will set at notification time. If you intend to run this notification on slaves, you should test on those servers too:
su - nagios
/usr/local/nagios/utils/test_notifications hostproblem /path/to/notificationscript {other parameters}
  • Put your script into /usr/local/nagios/plugins/notifications on the Opsview master server, as the nagios user
  • If appropriate, run send2slaves -p to distribute to all slaves
  • Create a new Notification Method (Advanced ⇒ Notification Methods). Set appropriate configuration (see above)
  • Each contact will then have to select this notification method to one of their notification profiles
  • Reload Opsview to make the changes live
  • Cause a failure to test that the notification is sent

Writing Your Own Notification Script

Your notification script should be written to expect any input regarding the notification alert from Nagios Core via environment variables - see the Macro Availability Chart at http://nagios.sourceforge.net/docs/3_0/macros.html.

The only environment variables available for notification methods are:

  • CONTACTEMAIL
  • CONTACTGROUPLIST
  • CONTACTNAME
  • CONTACTPAGER
  • HOSTACKAUTHOR
  • HOSTACKCOMMENT
  • HOSTADDRESS
  • HOSTALIAS
  • HOSTATTEMPT
  • HOSTDOWNTIME
  • HOSTGROUPNAME
  • HOSTNAME
  • HOSTOUTPUT
  • HOSTSTATE
  • HOSTSTATETYPE
  • LASTHOSTCHECK
  • LASTHOSTDOWN
  • LASTHOSTSTATE
  • LASTHOSTSTATECHANGE
  • LASTHOSTUNREACHABLE
  • LASTHOSTUP
  • LASTSERVICECHECK
  • LASTSERVICECRITICAL
  • LASTSERVICEOK
  • LASTSERVICESTATE
  • LASTSERVICESTATECHANGE
  • LASTSERVICEWARNING
  • LASTSTATECHANGE
  • LONGDATETIME
  • LONGHOSTOUTPUT
  • LONGSERVICEOUTPUT
  • NOTIFICATIONNUMBER
  • NOTIFICATIONTYPE
  • SERVICEACKAUTHOR
  • SERVICEACKCOMMENT
  • SERVICEATTEMPT
  • SERVICEDESC
  • SERVICEDOWNTIME
  • SERVICEOUTPUT
  • SERVICESTATE
  • SERVICESTATETYPE
  • SHORTDATETIME
  • TIMET

For example, in perl, reference the environment variables with:

print "$ENV{NAGIOS_HOSTNAME}\n";

In bash, reference the environment variables with:

echo $NAGIOS_HOSTNAME

A useful trick in bash to see all available environment variables is to add at the top of a notification method:

{ date; echo "Called with $@"; env; echo; } >> /tmp/env.txt

To distinguish between a service alert and a host alert, do something like (in perl):

if ( $ENV{NAGIOS_SERVICEDESC} ) {
  # This is a service alert
} else {
  # This is a host alert
}

Global settings should be stored either in the script or via command arguments.

You can then add this notification script to Opsview.

OUTPUT

The environment variables SERVICEOUTPUT, HOSTOUTPUT, LONGSERVICEOUTPUT, LONGHOSTOUTPUT hold the output from a plugin. The first two hold only the first line of the output, while the remainder is in the LONG… variables.

Note that the left and right angle brackets (<>) are stripped from the output.

CONTACTGROUPLIST

This environment variable holds all the contact groups that this host/service belongs to, in a comma separated list. Contact groups will be of the form:

  • hostgroupX_servicegroupY
  • kZ_NAME

You can use this to get the list of keyword names that the host/service is related to by:

@keywords = grep { s/k\d+_// } (split ",", $ENV{NAGIOS_CONTACTGROUPLIST})

References

Navigation
Print/export
Toolbox