Get status updates from SensuGo directly in Discord!
B
Clone the repository
git clone https://github.com/runarsf/sensugo-discord-handler.git
B
Add it to path (in this example/usr/local/bin
)
ln -s $(pwd)/sensugo-discord-handler.py /usr/local/bin/sensugo-discord-handler
- 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).
B
Modifyhandler.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 totrue
to enable embedded messages, if set to anything else the script will generate a plain text table.
B
Create the Handler from the file.
sensuctl create --file handler.json
# You should now have a new handler in your SensuGo WebUI
B
Create/Update your check(s) Adddiscord
to thehandlers
array in your check, take a look atcheck.json
for an example.B
(Re)create the Check from the file
sensuctl create --file check.json
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.
https://docs.sensu.io/sensu-go/5.11/reference/handlers/
Note: SensuGo handlers are run on the Backend, not on the Agent.
sensugo-discord-handler © runarsf · Author and maintainer.
Released under the MIT License.