[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [hobbit] http response time
- To: hobbit (at) hswn.dk
- Subject: Re: [hobbit] http response time
- From: "Ralph Mitchell" <ralphmitchell (at) gmail.com>
- Date: Fri, 9 May 2008 15:45:17 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=/iTzECPEyujd7iU4TbEfqnziUfqXw3iAUNwcB9rCVQk=; b=O23x+FfKELXTaGWZIUIWPFG/w74qTAZstImyJMr5i/RHgCslRFCTArJDFFqBZwj7r4OP2yJNB+9dLiy0G8jjrLw3sEuJnT6tj+Mo6bhR9KgARva9T3uOtmcVPIP3Na3Yj38duTzCjTjguA432U4Z8TO0GLr8eaBKVoIvwL4qPCw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=Di3yDRazCtKsetFWGA38jjzJecthHZoEjxKGZmSPlWUE11QGs7hwOpYUkyKG/M1rRiiCohF5mdRTzZsT9z1hiaQxwQxe3Q6xHH/mjaadKDBUMqI96h9FZSkV7qfDyz4PX9XCHiSLP9BN73KTRYiENNHSypYzrWeVzSym7hsEJfo=
- References: <997a524e0805071412t44e7e6ccv3280989434df110d (at) mail.gmail.com> <48229748.5040201 (at) hebis.uni-frankfurt.de> <997a524e0805080811r4dee6bf8tec0a041bb4b518f0 (at) mail.gmail.com>
On Thu, May 8, 2008 at 10:11 AM, Ralph Mitchell <ralphmitchell (at) gmail.com>
wrote:
> On Thu, May 8, 2008 at 1:01 AM, Rolf Schrittenlocher <
> schritte (at) hebis.uni-frankfurt.de> wrote:
>
>> Hi Ralph,
>>
>> I don't think there is something like that in hobbit. But you might want
>> to create a custom script including something like (perl)
>>
>> # Aktuelles Datum
>> $t0 = time;
>> $ZEITSTEMPEL = localtime($t0);
>>
>> ##################################################################
>> # Check Website
>> ##################################################################
>> #
>> system("wget -o /dev/null -O /tmp/ \"$REQUEST\" 2>/dev/null");
>>
>> # Bestimmung des Ergebnissstatuses aus der Antwortzeit.
>> $elapsed = time - $t0;
>> if ( $elapsed <= 6 ){
>> $STATUS = $OPTIMAL;
>> }
>> elsif ( $elapsed <= 12 ){
>> $STATUS = $WARNUNG;
>> }
>> else {
>> $STATUS = $FEHLER;
>> }
>
>
> Thanks for that. If I have to I'll do something similar in bash with curl,
> as I'm more familiar with that:
>
> elapsed=`curl -s -S -L -w '%{time_total}' http://server.domain.com`
>
> which gives me time in seconds, with millisecond resolution.
>
> I'd like to get the graphs as well, without having to fiddle with the
> message format.
>
> Ralph Mitchell
>
OK, so it wasn't as hard as I thought to replicate the http built-in test.
This script does everything I need right now, though it could do with
refining:
#!/bin/bash
# Format in bb-hosts: 1.2.3.4 server.domain.com # httpplus:warn:alert
# warn and alert values are expressed in milliseconds, just because we can
bbhostgrep httpplus\* | while read line
do
set $line
TESTHOST=$2
httpplus=`echo $line | $SED -e 's/^.* httpplus://' -e 's/ .*//' -e 's/:/
/g'`
set $httpplus
WARNVAL=$1
ALERTVAL=$2
URL="http://$TESTHOST/"
res=`/usr/bin/curl -I -s -S -w 'Seconds:\t%{time_total}' $URL`
ret=$?
elapsed=`echo "$res" | $GREP Seconds: | $SED -e 's/^.* //'`
elapsed=`echo $elapsed \* 1000 | /usr/bin/bc | $SED -e 's/\..*//'`
if [ "$elapsed" -gt "$ALERTVAL" ]; then
COLOR=red
STATUS="Server too slow"
elif [ "$elapsed" -gt "$WARNVAL" ]; then
COLOR=yellow
STATUS="Server response degraded"
else
COLOR=green
STATUS="OK"
fi
MACHINE=`echo $TESTHOST | $SED -e 's/\./,/g'`
LINE="status $MACHINE.http $COLOR `date`: $STATUS
&$COLOR $URL - $STATUS
$res
WARN at ${WARNVAL}ms, ALERT at ${ALERTVAL}ms"
$BB $BBDISP "$LINE"
done
It assumes that it's OK to use the hostname field for the url, and picks up
the WARN and ALERT times from the "httpplus" tag in the bb-hosts file. It
also ignores any curl errors, such as timeout due to the server not
responding.
Ralph Mitchell