#!/bin/sh # # benchmark-bf.sh # # Sends benchmark_rt data to the BB Display # Also computes alerts using benchmark-alert.pl script # # Global Variables: MET=benchmark OUT=/tmp/benchmark.$$ STATUS=green # Please give here the name of the dump file used # by benchmark_rt to store the data (see in the Apache # configuration file) DUMPNAME=/tmp/benchmark.dump HLPPGM=benchmark_rt ALERTPGM=bf/benchmark-alert.pl # ------------------------------------------------- # 1-Check 'benchmark_rt' exists: # ------------------------------------------------- rm -f $DUMPNAME # We could also have check with the PID stored in # /tmp/benchmark.pid, but this is a safer method: #killall -USR1 $HLPPGM killall -USR2 $HLPPGM # USR1 dumps all the URI requested since the start # USR2 dumps only the URI requested since the last dump # Wait til the file is generated (a bit ugly...) sleep 2 if [ ! -s "$DUMPNAME" ] then # ----------------------------- # 2a-Error handling: # ----------------------------- STATUS=red cat <<END > $OUT The 'benchmark_rt' process did not produce any statistics. Please, check it is well running. END else # ----------------------------------- # 2b-Read the data to be sent to BB: # ----------------------------------- # But before, we call the alerter process that will # determine for which URIs the response time reached # the thresholds: $ALERTPGM $DUMPNAME case "$?" in 0) STATUS=green;; 1) STATUS=yellow;; 2) STATUS=red;; *) STATUS=red cat <<END > $OUT The alerter program 'benchmark-alert.pl' returned an unknown error code. END DUMPNAME=$OUT ;; esac OUT=$DUMPNAME fi # --------------------------------------- # 8-Send the results to the BB Display: # --------------------------------------- if [ "$LARRDCOMM" = DATA ] then $BB $BBDISP "data ${MACHINE}.$MET `$CAT $OUT`" else $BB $BBDISP "status ${MACHINE}.$MET $STATUS `date` <$MET> `$CAT $OUT`" fi # -------------- # 9-Cleanup... # -------------- if [ "$OUT" != "$DUMPNAME" ] then rm $OUT fi # EOF