Skip to content

Instantly share code, notes, and snippets.

@replsv
Created April 7, 2017 20:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save replsv/d8d0c639cbf5558c3bc83b46632152c7 to your computer and use it in GitHub Desktop.
Save replsv/d8d0c639cbf5558c3bc83b46632152c7 to your computer and use it in GitHub Desktop.
Slack log file watcher
#!/bin/bash
SLACK_HOOK_URL="https://hooks.slack.com/services/SOME/SPECIAL/TOKEN"
SLACK_CHANNEL="#production-logs"
tail -n0 -F "$1" | while read LINE; do
(echo "$LINE") && curl -X POST --silent --data-urlencode \
"payload={\"channel\": \"$SLACK_CHANNEL\", \"mrkdwn\": true, \"text\": \"$(echo $LINE | sed "s/\"/'/g") | File: ${1} | Server: $(hostname)\"}" $SLACK_HOOK_URL;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment