3 export SGMONDIR="$(dirname "$(realpath -- "$0")")"
5 [ -z "$1" ] && SGMONSRV="$(basename "$PWD")" || SGMONSRV="$1"
7 export SGMONTMP=`mktemp -d -t sgmon`
8 trap "rm -fr $SGMONTMP" HUP PIPE INT QUIT TERM EXIT
13 [ -s max-attempts ] && read max_attempts < max-attempts || max_attempts=1
14 [ -s state/attempts ] && read attempts < state/attempts || attempts=0
15 if ./run >state/stdout 2>state/stderr ; then
16 if [ "$attempts" -ge "$max_attempts" ] ; then
17 "$SGMONDIR"/notify-ok.sh
24 attempts=$(( $attempts + 1 ))
25 echo $attempts > state/attempts
26 echo BAD ${attempts}/${max_attempts}
27 if [ $attempts -eq $max_attempts ] ; then
28 "$SGMONDIR"/notify-bad.sh
31 [ -s period ] && read period < period || period=$PERIOD_DEFAULT