Giter Site home page Giter Site logo

sensugo-discord-handler's Introduction

sensugo-discord-handler

Get status updates from SensuGo directly in Discord!

Setup (Backend Agent)

  1. B Clone the repository
git clone https://github.com/runarsf/sensugo-discord-handler.git
  1. B Add it to path (in this example /usr/local/bin)
ln -s $(pwd)/sensugo-discord-handler.py /usr/local/bin/sensugo-discord-handler
  1. Create a Discord Webhook
  • Open Discord (Desktop / Web, not currently available on mobile app) and navigate to the channel you want the status messages to be posted in
  • Click Edit Channel > Webhooks > Create Webhook
  • Name the webhook something recognizable, the name will only matter when managing it, as the name visible in chat will be provided by the script.
  • Same goes for the icon, the script will provide a custom one.
  • Take note of the WEBHOOK URL, you will need it later (you can view it at any time).
  1. B Modify handler.json file to match your setup.
  • spec > command: Full path or script registered in path.
  • spec > filters: Conditions for which events to trigger the handler.
  • spec > env_vars[WEBHOOK_URL]: The URL you got when creating the webhook.
  • spec > env_vars[USERNAME]: The display name of the bot-user that posts the status messages.
  • spec > env_vars[ICON_URL]: The icon of the bot-user that posts the status messages.
  • spec > env_vars[USE_EMBED]: Set to true to enable embedded messages, if set to anything else the script will generate a plain text table.
  1. B Create the Handler from the file.
sensuctl create --file handler.json
# You should now have a new handler in your SensuGo WebUI
  1. B Create/Update your check(s) Add discord to the handlers array in your check, take a look at check.json for an example.
  2. B (Re)create the Check from the file
sensuctl create --file check.json

Running a manual test (requires the ENV var WEBHOOK_URL)

export WEBHOOK_URL=https://discordapp.com/api/webhooks/AAAAAA/BBBBBBBBB
cat example.json | ./sensugo-discord-handler

You can also remove the spec > filters array from handler.json and recreate the handler to get it to run every time a check assigned to it runs.

SensuGo Handler Docs

https://docs.sensu.io/sensu-go/5.11/reference/handlers/
Note: SensuGo handlers are run on the Backend, not on the Agent.

Screenshots

USE_EMBED=False USE_EMBED=True SensuGo Dashboard

sensugo-discord-handler © runarsf · Author and maintainer.
Released under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.