Skip to content

Instantly share code, notes, and snippets.

@tamanugi
Created August 17, 2016 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamanugi/96666d25d3fcdd81f0e1c47d09f64da3 to your computer and use it in GitHub Desktop.
Save tamanugi/96666d25d3fcdd81f0e1c47d09f64da3 to your computer and use it in GitHub Desktop.
tailコマンドでログを監視して、slackにアラート投げる ref: http://qiita.com/tamanugi/items/575d873546355a6edff7
$ ./slack_alert.sh output.log
#!/bin/sh
slack_alert() {
while read i
do
echo $i | grep -q "Finish."
if [ $? = "0" ];then
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"Finish!!"}' \
https://hooks.slack.com/services/{Incoming Webhook URL}
fi
done
}
tail -n 0 --follow=name --retry $1 | slack_alert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment