Skip to content

Instantly share code, notes, and snippets.

@ramonjoaquim
Last active July 28, 2020 17:44
Show Gist options
  • Save ramonjoaquim/0dc2bf524c7811a41b930ecf46b3769c to your computer and use it in GitHub Desktop.
Save ramonjoaquim/0dc2bf524c7811a41b930ecf46b3769c to your computer and use it in GitHub Desktop.
Send notification of zabbix to Rocket.Chat - script generic
#!/bin/bash
URL_TOKEN="url webhook from Rocket.Chat"
# Params get by request - add params on zabbix on type of media configuration settings to match a script params
USER="$1"
SUBJECT="$2"
MESSAGE="$3"
# Change color emoji depending on the MESSAGE contains property - Green (RECOVERY), Red (PROBLEM), Yellow (UPDATE)
if [[ "$MESSAGE" == *"#OK"* ]]; then
COLOR="#00ff33"
elif [[ "$MESSAGE" == *"#UPDATE"* ]]; then
COLOR="#ffcc00"
elif [[ "$MESSAGE" == *"#PROBLEM"* ]]; then
COLOR="#ff2a00"
fi
# Payload of request
PAYLOAD='{"username":"'$USER'","attachments":[{"color":"'${COLOR}'","title":"'${SUBJECT}'","text":"'${MESSAGE}'"}]}'
curl -X POST -H 'Content-Type: application/json' --data "${PAYLOAD}" $URL_TOKEN
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment