#!/bin/sh # # (Not so) simple shell script to watch if a running process... # # When the process is not running anymore a notification will be sent through # the boxcar provider api using curl. # # written by Fabian Meyer (fm_scripts at noinfo.de) # CURL=`which curl` # fill in the boxcar fields for your own provider TOKEN="" SECRET="" PROVIDER="" # this is the part of your demo-url after # http://boxcar.io/devices/providers/ ############################################################################ if [ "$1" = "" ]; then echo "Usage: $0 [processname]" exit 1 fi OK="ok" NOTOK="not" RUNNING=$OK while [ "$RUNNING" = "$OK" ]; do ps aux |grep -v grep | grep -v watch_process.sh |grep $1 > /dev/null if [ "$?" = "0" ]; then RUNNING=$OK else RUNNING=$NOTOK $CURL -d "token=$TOKEN&secret=$SECRET¬ification[from_screen_name]=$1" \ -d "¬ification[message]=Not+running+on+$HOSTNAME." \ http://boxcar.io/devices/providers/$PROVIDER/notifications # This makes only sense if the script is called after the process finishes not # for watching ps +Exit+code+$? fi done exit 0