zabbix-discord
zabbix-discord copied to clipboard
Alertscript for zabbix to enable discord notifications
Overview
This is an alert-script for notifications to Discord, issued from Zabbix. It uses Discord-webhooks.
Prerequisites
- Discord Webhook Howto Setup Discord Webhook
Installation
- set env WEBHOOK_URL to your previously setup discord-web-hook-url in
discord.sh
(e.g.https://discordapp.com/api/webhooks/xxx/yyy
) - (optional) set env ZABBIX_URL in bash-script
discord.sh
to aim towards your zabbix installation (e.g.https://zabbix.your-domain-bleh.foo/
), this will be used to link the discord-messages to your zabbix installation - configure
AlertScriptsPath
of your zabbix installation - Zabbix Howto - add the
discord.sh
script to your zabbixAlertScriptsPath
directory - make sure zabbix can access that file and it also has execution permission (
chmod +x discord.sh
) - configure your custom alertscript in zabbix - Zabbix Howto,
script parameters are (as shown in zabbix documentation):
{ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}
- add media to a zabbix-user to be notified that way, the "Send to"-field is the discord-channel name here, e.g. #zabbix.
- (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, OK or Resolved (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