Skip to content

Instantly share code, notes, and snippets.

@jarosite
Last active March 26, 2016 15:53
Show Gist options
  • Save jarosite/5c881745d2b5265c2d9a to your computer and use it in GitHub Desktop.
Save jarosite/5c881745d2b5265c2d9a to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
set -x
#{
#date
export zabbixemailto=$1
export zabbixsubject=$2
export zabbixbody=$3
slack_web_hook_url=https://hooks.slack.com/services/#####/#####/##########
if [[ "$zabbixsubject" =~ ^PROBLEM.* ]]; then
emoji=':thinking_face:'
color=danger
else
emoji=':smile:'
color=good
fi
curl -X POST --data-urlencode "payload={\"channel\": \"$zabbixemailto\", \"username\": \"zabbix_spammer\", \"icon_emoji\": \"$emoji\", \"attachments\":[ { \"fallback\":\"$zabbixsubject\", \"pretext\":\"$zabbixsubject\", \"text\": \"$zabbixbody\" , \"color\":\"$color\"} ]}" $slack_web_hook_url
#} 2>&1 | tee /var/log/zabbix_sendslack.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment