Created
April 7, 2017 20:27
-
-
Save replsv/d8d0c639cbf5558c3bc83b46632152c7 to your computer and use it in GitHub Desktop.
Slack log file watcher
This file contains 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 | |
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