Created
August 17, 2016 11:44
-
-
Save tamanugi/96666d25d3fcdd81f0e1c47d09f64da3 to your computer and use it in GitHub Desktop.
tailコマンドでログを監視して、slackにアラート投げる ref: http://qiita.com/tamanugi/items/575d873546355a6edff7
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
$ ./slack_alert.sh output.log |
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 | |
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