#!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin [[ ! -x `which curl` ]] && echo install curl first && exit 1 [[ ! -x `which dos2unix` ]] && echo install dos2unix first && exit 1 webhook={{slack_webhook_sev3}} #webhook_icon_url= [[ -z $2 ]] && echo username and message body ? && exit 1 username="$1" body="$2" # owned by root vs user (e.g. zabbix) might bring permission issues tmpfile=`mktemp` echo "$body" > $tmpfile dos2unix $tmpfile # self-verbose echo -n sending webhook ... curl -fsSX POST -H 'Content-type: application/json' \ -d "{ \"text\": \"\`\`\` `cat $tmpfile` \`\`\`\", \"username\": \"$username\" }" $webhook; echo #"channel": "$webhook_channel", #"icon_url": "$webhook_icon_url",