Created
November 15, 2018 16:59
-
-
Save K0rell/2c8d3c2fd695aafe00567649b30e74c5 to your computer and use it in GitHub Desktop.
Zabbix Alert in slack channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requirement curl | |
# Create new script in nano /usr/lib/zabbix/alertscripts/media-slack.sh | |
# chmod +x media-slack.sh | |
# Create Slack App https://api.slack.com/apps/new | |
# Choose your app | |
# Select and active Incomming Webhooks | |
# Choose your channel to send messages | |
# Get the webhooks URL and update the script ! | |
# ZABBIX Administration > Media types > Create media type | |
# Name = Slack | |
# Type = Script | |
# Script name = media-slack.sh | |
# Script parameters (one per line with {}) = {ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE} | |
# Administration > User > Media > Add (to slack channel) | |
TO=$1 # {ALERT.SENDTO} not used | |
MESSAGE="$2\n$3" # {ALERT.SUBJECT} \n {ALERT.MESSAGE} | |
curl -X POST -H 'Content-type: application/json' --data @<(cat <<EOF | |
{ | |
"text": "$MESSAGE", | |
} | |
EOF | |
) https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXXXXX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment