I had been wondering about monitoring web response time, like
keynote & other services. In searching the BB archives I found
someone had suggested using time with wget. The only problem I
found with this is that wget does not do parallel gets which I
can live with.
Here is how I adapted it into big brother:
It works off a wwwtime:// option in the bb-hosts:
example bb-hosts:
216.103.214.55 www.dmzs.com # http://www.dmzs.com/ wwwtime://www.dmzs.com/
#---------------------
I added the following to bbdef.sh:
bbdef.sh:
#
# DMZ New Web time response testing
#
TIME="/usr/bin/time --format=%E"
WGET="/usr/bin/wget --no-parent -t 1 -T 15 -r -l1 -A.gif -A.jpg -A.png"
#MAXTIME is HOUR(1D):SECONDS(2D).MICROSECONDS(2D)
#where D is number of digits, so 01500 is 15 seconds
MAXTIME="01500"
export TIME WGET MAXTIME
#---------------------
And Added MKDIR to bbsys.sh:
MKDIR="/bin/mkdir -p" # DMZ wwwtime
## Note: (don't forget to add MKDIR to the export line):
export PING LS MKDIR FIND TOUCH CAT GREP SORT UNIQ DATE TAIL SED UPTIME WC WHO RM EXPR
#---------------------
And finally, I added the following to bin/bb-network.sh right before http* )
bb-network.sh:
#
# DMZ 0.1 - www time response testing 20010211
# dmz@dmzs.com
#
wwwtime* ) #echo "DOING WWW Time Response Test..."
OLDIFS=$IFS
IFS='|'
set $1
IFS=$OLDIFS
URLS=$*
COLOR="green"
LINE="Server Response Time OK"
for URL in $URLS
do
#echo $URL
DOMAIN=`echo $URL | sed 's/wwwtime:\/\///'`
LOGFILE="$BBTMP/$DOMAIN/wget.log"
# In case they have subdirs they are checking, wget needs to have base path setup
$MKDIR $BBTMP/$DOMAIN
$TIME -o $BBTMP/$DOMAIN/.time $WGET -P $BBTMP/$DOMAIN/ -o $LOGFILE http://$DOMAIN 2>&1
read RESPONSETIME < $BBTMP/$DOMAIN/.time
RTIME=`echo $RESPONSETIME | sed 's/\.//' | sed 's/://'`
if [ $RTIME -gt $MAXTIME ]
then
# If Not OK, check again to be sure
$RM -fr $BBTMP/$DOMAIN
$MKDIR $BBTMP/$DOMAIN
$TIME -o $BBTMP/$DOMAIN/.time $WGET -P $BBTMP/$DOMAIN/ -o $LOGFILE http://$DOMAIN 2>&1
read RESPONSETIME < $BBTMP/$DOMAIN/.time
RTIME=`echo $RESPONSETIME | sed 's/\.//' | sed 's/://'`
if [ $RTIME -gt $MAXTIME ]
then
COLOR="red"
LINE="Server Response **NOT** OK"
fi
fi
LINE="${LINE} &$COLOR $URL - Responsetime: $RESPONSETIME<hr><pre>`cat $LOGFILE`</pre>"
done
$BB $BBDISP "status ${MACHINE}.wwwtime $COLOR `date` $LINE"
$RM -fr $BBTMP/$DOMAIN
;;
#---------------------
Let me know if anyone has alternatives or problems.
dmz