Opsview custom SMS notifications
Opsview can now use custom SMS notification methods. I've prepared a mini-howto guide on how to use this feature. Please send in comments, corrections and suggestions. This article will be aported to the Opsview docs, so all of us will benefit.
Configuring Opsview
Put your custom SMS notification script into
/usr/local/nagios/libexec/notificationsremember to make it executable to the nagios user. See below for recommendations on how to develop the notification methods.
Sync the plugins to the slaves:
/usr/local/nagios/bin/send2slaves
In Opsview interface
Go to: Advanced -> SMS Notifications -> Create new SMS Notification Methods
- Name: give it an identifier (without spaces)
- Run On:
- Monitoring Server: The command will be run on the Master monitoring server. This is for scenarios where you have to notify from a special device, for example, that isn't available on the slaves. A cell phone attached via a serial cable, a server that is only accessible from the master, etc.
- Slave: This means the command will be run on the slave that has detected the alert. This is for notification services that will not depend on the server that detected the alert, like an HTTP call to an SMS service.
- Command: the name of the command in the /usr/local/nagios/libexec/notifications directory. Add extra parameters that are supposed to get to the script (parameters that nagios doesn't send you).
Go to: Advanced -> System Preferences, choose your new SMS method identifier, and submit the changes
Be sure to have a contact with the SMS number filled in (that will activate the SMS notifications for that contact). Note that the +CCNNNNNNNNN format is not longer enforced, in fact, no format is enforced, as it will be the plugins responsability to verify the correct format for the number for it's use. Push the "send test SMS" link to try out your notification method.
Reload your Opsview configuration and you're running
More help is available in Opsview docs.
Script guide
The script will recieve the SMS number in the NAGIOS_CONTACTPAGER environment variable, in fact, it can play around with all the environment variables listed in the Nagios Macros Reference. Look in the Service Notifications and the Host Notifications column.
Non-Nagios variables can be expected from the command parameters. Things like --url_to_post_to, --serial-device-to-talk-to --baud-rate, etc, and can be passed when you define the "Command" of the new SMS method.
Do the notification magic, print a line of status to STDOUT to help out humans ;), and exit 0 on success, non-zero on failure.
Note: The Opsview 2.11 standard notification scripts relied on getting the SMS number via the command line with -n parameter (if I don't remember badly). These where changed to be expected through the env variables in Opsview 2.12.
Power to the users
Who says "custom SMS notifications" says "do what you want to notify... you have the control". That is, as long as you fill in the SMS number for a contact, the "SMS" notification will be called for it. You can write a log file instead of sending an SMS if you want... Opsview won't care }:)