Created
April 18, 2016 04:40
-
-
Save soramugi/f2ed4529479a3345609c469e3ac628f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
# sleep 180& | |
# nohup bash ifttt.sh 51666 > /dev/null 2>&1 & | |
CURL=/usr/bin/curl | |
IFTTT_EVENT="push" | |
IFTTT_KEY="xxxxxxxxxxxxxxxxxxx" | |
IFTTT_URL="https://maker.ifttt.com/trigger/${IFTTT_EVENT}/with/key/${IFTTT_KEY}" | |
PROCESS_NAME="" | |
if [ ! -v $1 ]; then | |
PROCESS_NAME=`cat /proc/$1/cmdline` | |
fi | |
send_notification(){ | |
${CURL} -X POST \ | |
${IFTTT_URL} \ | |
--header "Content-Type: application/json" \ | |
--data-binary "{\"value1\": \"${PROCESS_NAME}\"}" | |
printf "\n" | |
} | |
while true | |
do | |
if [ -v $1 ]; then | |
send_notification | |
break | |
else | |
kill -0 $1 > /dev/null 2>&1 | |
if [ $? = 0 ]; then | |
echo "alive" | |
else | |
echo "dead" | |
send_notification | |
break | |
fi | |
sleep 3 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment