Created
November 4, 2014 10:31
-
-
Save etobi/109f0b13091db1be002a to your computer and use it in GitHub Desktop.
Simple shell script to monitor a log file (e.g. TYPO3 syslog) and push it to a slack channel
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/sh | |
tail -n 1 -f /var/path/to/file.log | while read line; do | |
echo $line | grep -v "PATTERN TO IGNORE" | |
if `test $? -eq 0`; then | |
cleanLine=`echo $line | tr -d '"'` | |
payload="payload={\"channel\": \"#channel\", \"username\": \"dev:typo3-sys.log\", \"text\": \"$cleanLine\", \"icon_emoji\": \":interrobang:\"}" | |
curl -X POST --data-urlencode "$payload" https://TEAM.slack.com/services/hooks/incoming-webhook\?token\=TOKEN | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment