Back to OP5 Monitor FAQ

How to integrate OP5 Monitor with Slack

notify_slack.py tested and worked on OP5 Monitor version 9 using Python version 2.

Support information Copied

This article was written for version 7.2.9 of OP5 Monitor. It could work on both lower and higher version if nothing else is stated. The Slack integration and its dependencies are third-party add-ons. These are not officially supported by OP5 AB. If you need a supported integration between OP5 Monitor and Slack, please contact us!

By integrating Slack into your existing OP5 monitoring solution, you can have OP5 alerts sent directly to your teams Slack channel. See the screenshot below for the end result.

Screenshots Copied

OP5 Monitor - How to integrate OP5 Monitor with Slack

In Slack Copied

  1. Go to https://api.slack.com/apps?new_app=1

  2. Create a Incoming WebHook and tie it to your teams channel, like for example #devops

    OP5 Monitor - How to integrate OP5 Monitor with Slack

  3. Make a note of the Webhook URL, this is your token we will be using later:

    OP5 Monitor - How to integrate OP5 Monitor with Slack

In OP5 Monitor Copied

To tie Slack to OP5 Monitor, we will need to configure the following:

  1. Upload the Slack plugin onto your OP5 Monitor server;
  2. Create check commands ‘host-notify-slack’ and ‘service-notify-slack’;
  3. Create a Slack contact.

Uploading the Slack plugin onto your OP5 server Copied

Upload the plugin notify_slack.py attached in this article to your OP5 server(s) into the directory: /opt/plugins/custom/

Change the permissions on the notify_slack.py file to 755, by issuing the command: chmod 744 /opt/plugins/custom/notify_slack.py

Create check commands (host-notify-slack and service-notify-slack) Copied

The slack integration is tied to check commands, that is later tied to your Slack contact we will be creating in the last step.

  1. From the Manage menu select Configuration and click on Commands
  2. Configure two check commands, one named host-notify-slack and service-notify-slack with the settings as described below**:**
host-notify-slack
       command_name: host-notify-slack
       command_line: $USER1$/custom/notify_slack.py -c "$ARG1$" -t "$ARG2$" -X "$ARG3$" -H "$HOSTNAME$" -L "$HOSTSTATE$" -m "$HOSTOUTPUT$" -U "OP5 Monitor"

service-notify-slack
       command_name: service-notify-slack
       command_line: $USER1$/custom/notify_slack.py -c "$ARG1$" -t "$ARG2$" -X "$ARG3$" -H "$HOSTNAME$" -L "$SERVICESTATE$" -S "$SERVICEDESC$" -m "$SERVICEOUTPUT$" -U "OP5 Monitor"

OP5 Monitor - How to integrate OP5 Monitor with Slack

Create a Slack contact Copied

  1. From the Manage menu select Configuration and click on Contacts
  2. Create a new contact, give it a name like for example: Slack
  3. Set host_notification_cmds, host_notification_cmds_args and service_notification_cmds, service_notification_cmds_args as described below:
host_notification_cmds: host-notify-slack
host_notification_cmds_args: "<#channel>"!"<token/webhook_url>"!"https://url-to-op5"

service_notification_cmds: service-notify-slack
service_notification_cmds_args: "<#channel>"!"<token/webhook_url>"!"https://url-to-op5"

Here's an example from our OP5 Monitor environment:
host_notification_cmds: host-notify-slack
host_notification_cmds_args: "#devops"!"https://hooks.slack.com/services/TXXXX/B2XXXX/EflrMrZTNlOKEbXXXXXXR"!"https://demo.op5.com"

service_notification_cmds: service-notify-slack
service_notification_cmds_args: "#devops"!"https://hooks.slack.com/services/TXXXX/B2XXXX/EflrMrZTNlOKEbXXXXXXR"!"https://demo.op5.com"

That’s it! Copied

Finally, in order for OP5 Monitor to forward alerts to Slack you must assign the “Slack” contact you created earlier as a contact to a host or specific services.

["Geneos"] ["FAQ"]

Was this topic helpful?