Features Integrations

Integrating Slack with Pandora FMS

February 6, 2015

Integrating Slack with Pandora FMS

This post is also available in: Spanish


Slack-icon

Developing a powerful monitoring software is not a silly thing. He have to communicate with other departments all the time, so that, the Pandora FMS team need a complete tool as Slack to improve the communication in their internal processes.

Before using Slack, we had to send more e-mails, use different chat applications such as jabber or gtalk and sometimes waste our time with non oficial Whatsapp groups. Go to other rooms to ask a simple question, write down messages in the blackboard, or spend 20 post-it a day…. Do you want to keep doing that? Really??

Today we consider Slack one of the best improvements, together with GitHub, in the internal processes and methodologies of Pandora FMS in 2014. Integration is as easier as you can’t imagine. If you are the kind of person that can’t wait to see how this app works, keep reading and pay attention:

1. Create the “Incoming webhook”

Through a REST call we will do the rest. Here the URL call is defined (Slack gives you the URL you have to call to) and the channel where all the warnings will be sent to. So simple that there’s no need to explain:

Captura de pantalla 2015-02-05 a la(s) 00.20.56

 

Copy the last data “chunk” of the webhook URL. In this screenshot “wAJAxKpfOmgDl” is the identifier that you will need for the script of the new step. Needless to say that this value is different in each case.

2. Create a script to execute the alert command

#!/bin/bash

# Generic integration script with Slack for sending messages from Pandora FMS

# (c) 2014 Sancho Lerena

# SET HERE YOUR DATA

USERNAME=pandorafmsbot

ICON=”http://cdn9.staztic.com/app/a/3528/3528476/pandora-fms-1-l-78×78.png”

CHANNEL=”#pandorafms_events”

URL=”https://artica.slack.com/services/hooks/incoming-webhook?token=wAJAxKpfOmgDl”

# Do not touch from there:

MSG=”‘payload={\”channel\”: \”$CHANNEL\”, \”username\”: \”$USERNAME\”, \”text\”: \”$1\”, \”icon_url\”: \”$ICON\”}'”

COMMAND=”curl -X POST –data-urlencode $MSG $URL”

eval $COMMAND

It’s easy right? The only thing you have to change is the text chain behind the “token=” when defining the URL. Take the value of the previous step.

Save it in an script, give it execution permissions (chmod 755). Test if it works. Just execute the command (I have it in root/slack.sh) this way:

[[email protected] ~]# ./slack.sh “PandoraFMS y Slack resurgen de sus cenizas”

This will generate an entry like this in your slack channel:

Captura de pantalla 2015-02-05 a la(s) 00.25.02

3. Create an alert command in Pandora FMS

Something trivial for anyone who has already worked with Pandora FMS, but difficult if is the first time you create a command alert.

Captura de pantalla 2015-02-05 a la(s) 00.26.57

It’s not very complicated. We call a script and pass a parameter that is enclosed in double quotes. It’s the whole secret.

Now let’s create an Alert action to associate specific alerts that, when using a command jump to a condition.

4. Create an alert action in Pandora FMS

The purpose of this is to create a generic action that we can use in the 99% of situations.

Captura de pantalla 2015-02-05 a la(s) 00.31.29

Here we format a message type that gives us the agent information, the module and the module value when the alert is fired (using the alert macros showed in the screenshot). We also have to define the message in case of alert recovering.

5. Create an alert over module

We are almost there. We’ll take a module and create a new alert, associating the module (pending_datapackets) in the generic contition (critical condition) and using our newly created action in the previous step (Slack Formatted).

Captura de pantalla 2015-02-05 a la(s) 00.32.28

We will force a threshold of 1 day, so that the same warning notifies at most every 24 hours.

We’ll wait a little and we’ll have our first notification of slack. :)

Captura de pantalla 2015-02-05 a la(s) 00.37.07

If you have any doubt of how it works,  you can consult our forums http://forums.pandorafms.com where Sergio and Ivo we’ll be glad to help you.


    Written by:



    Leave a comment

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.