Last active
August 29, 2015 14:27
-
-
Save michabbb/a18387753cd8a1019a85 to your computer and use it in GitHub Desktop.
Notify a slack channel/user if a process is no longer running -- start with: ./slack_notify.sh <something you are watching for in the process list>
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_HOSTNAME="XXX.slack.com" | |
SLACK_URL="https://hooks.slack.com/services/XXXXXXXXXX" | |
SLACK_CHANNEL="@....." | |
SLACK_BOTNAME="XXXXXX" | |
OUTPUT=$(ps ax|grep "$1"|grep -v grep|grep -v $0) | |
if echo "$OUTPUT" | egrep -q "$1" ; then | |
echo "Still running: $1!" | |
else | |
echo "Notify SLack" | |
curl -X POST --data "payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"${SLACK_BOTNAME}\", \"text\": \"Finished: $1\"}" ${SLACK_URL} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment