webchi / zabbix-discord

Alertscript for zabbix to enable discord notifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overview

This is a script for notifications to Discord issued from Zabbix. It uses webhooks.

Prerequisites

Installation

  1. modify hard-coded zabbix urls in discord.sh to aim towards your zabbix installation ("url": "https://zabbix.your-domain-bleh.foo/")
  2. modify hard-coded discord urls including token in discord.sh to aim towards your prior setup discord endpoint (https://discordapp.com/api/webhooks/xxx/yyy)
  3. configure AlertScriptsPath of your zabbix installation - Zabbix Howto
  4. add the discord.sh script to your zabbix AlertScriptsPath directory
  5. make sure zabbix can access that file and it also has execution permission (chmod 755 discord.sh)
  6. configure your custom alertscript in zabbix - Zabbix Howto, script parameters are (as shown in zabbix documentation):
    {ALERT.SENDTO}
    {ALERT.SUBJECT}
    {ALERT.MESSAGE}
    
  7. add media to a zabbix-user to be notified that way, the "Send to"-field is the discord-channel name here, e.g. #zabbix.
  8. (optional) probably re-configure zabbix-action for different message-format

Additional Info

I build a regexp into the script to detect if it's either a PROBLEM or OK (never got things like {EVENT.VALUE} working)

Example webhook for discord

$ curl -X POST --data '{ "embeds": [{"title": "<NOTIFICATION TITLE>", "url": "<NOTIFICATION URL>", "description": "<NOTIFICATION BODY>", "type": "link", "thumbnail": {"url": "https://storage.googleapis.com/material-design/publish/material_v_12/assets/0Bx4BSt6jniD7dFBUNHdrY05jQ3c/style-logos-product-intro-definition.png"}}] }' -H "Content-Type: application/json" https://discordapp.com/api/webhooks/xxx/yyyy

Zabbix Media type config

Image of Discord-Notifcation

Zabbix User media config

Image of Discord-Notifcation

Discord notification in action

Image of Discord-Notifcation

About

Alertscript for zabbix to enable discord notifications

License:MIT License


Languages

Language:Shell 100.0%