On Thu, May 8, 2008 at 10:11 AM, Ralph Mitchell <<a href="mailto:ralphmitchell@gmail.com">ralphmitchell@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Thu, May 8, 2008 at 1:01 AM, Rolf Schrittenlocher <<a href="mailto:schritte@hebis.uni-frankfurt.de" target="_blank">schritte@hebis.uni-frankfurt.de</a>> wrote:<br></div><div class="gmail_quote">
<div class="Ih2E3d"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Ralph,<br>
<br>
I don't think there is something like that in hobbit. But you might want to create a custom script including something like (perl)<br>
<br>
# Aktuelles Datum<br>
$t0          = time;<br>
$ZEITSTEMPEL = localtime($t0);<br>
<br>
##################################################################<br>
# Check Website<br>
##################################################################<br>
#<br>
system("wget -o /dev/null -O /tmp/ \"$REQUEST\" 2>/dev/null");<br>
<br>
# Bestimmung des Ergebnissstatuses aus der Antwortzeit.<br>
$elapsed = time - $t0;<br>
if ( $elapsed <= 6 ){<br>
 $STATUS = $OPTIMAL;<br>
}<br>
elsif ( $elapsed <= 12 ){<br>
 $STATUS = $WARNUNG;<br>
}<br>
else {<br>
 $STATUS = $FEHLER;<br>
}</blockquote></div><div><br>Thanks for that.  If I have to I'll do something similar in bash with curl, as I'm more familiar with that:<br><br>   elapsed=`curl -s -S -L -w '%{time_total}' <a href="http://server.domain.com" target="_blank">http://server.domain.com</a>` <br>

</div></div><br>which gives me time in seconds, with millisecond resolution.<br><br>I'd like to get the graphs as well, without having to fiddle with the message format.<br><font color="#888888"><br>Ralph Mitchell<br>

</font></blockquote></div><br>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:<br><br>  #!/bin/bash<br><br>  # Format in bb-hosts:  <a href="http://1.2.3.4">1.2.3.4</a> <a href="http://server.domain.com">server.domain.com</a>  # httpplus:warn:alert<br>
  # warn and alert values are expressed in milliseconds, just because we can<br><br>  bbhostgrep httpplus\* | while read line<br>  do<br>    set $line<br>    TESTHOST=$2<br><br>    httpplus=`echo $line | $SED -e 's/^.* httpplus://' -e 's/ .*//' -e 's/:/ /g'`<br>
    set $httpplus<br>    WARNVAL=$1<br>    ALERTVAL=$2<br><br>    URL="http://$TESTHOST/"<br>    res=`/usr/bin/curl -I -s -S -w 'Seconds:\t%{time_total}' $URL`<br>    ret=$?<br><br>    elapsed=`echo "$res" | $GREP Seconds: | $SED -e 's/^.*        //'`<br>
    elapsed=`echo $elapsed \* 1000 | /usr/bin/bc | $SED -e 's/\..*//'`<br><br>    if [ "$elapsed" -gt "$ALERTVAL" ]; then<br>      COLOR=red<br>      STATUS="Server too slow"<br>    elif [ "$elapsed" -gt "$WARNVAL" ]; then<br>
      COLOR=yellow<br>      STATUS="Server response degraded"<br>    else<br>      COLOR=green<br>      STATUS="OK"<br>    fi<br><br>    MACHINE=`echo $TESTHOST | $SED -e 's/\./,/g'`<br>    LINE="status $MACHINE.http $COLOR `date`: $STATUS<br>
  &$COLOR $URL - $STATUS<br><br>  $res<br><br>  WARN at ${WARNVAL}ms, ALERT at ${ALERTVAL}ms"<br><br>    $BB $BBDISP "$LINE"<br>  done<br><br>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.<br>
<br>Ralph Mitchell<br>