Skip to content

Instantly share code, notes, and snippets.

@soramugi
Created April 18, 2016 04:40
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 soramugi/f2ed4529479a3345609c469e3ac628f7 to your computer and use it in GitHub Desktop.
Save soramugi/f2ed4529479a3345609c469e3ac628f7 to your computer and use it in GitHub Desktop.
#!/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