Skip to content

Instantly share code, notes, and snippets.

@etobi
Created November 4, 2014 10:31
Show Gist options
  • Save etobi/109f0b13091db1be002a to your computer and use it in GitHub Desktop.
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
#!/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