Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I create a custom response header called "Duration" that records the time taken to generate the response. And I set this header to be returned only when the request header "Client" with the value of "Get-Duration" is supplied:

% telnet

% telnet> o myhost.com

---request 1
GET /index.html HTTP/1.1
Host: myhost.com
Client: Get-Duration

-----response 1
HTTP/1.1 200 OK
...
Duration: D=123123
...

Using telnet and the "Duration" header above, how to devise and conduct tests to measure the performance of the web server when requesting the files?

Thanks a lot GURUs!!

share|improve this question

2 Answers 2

You're doing it wrong and reinventing the wheel.

Just use curl:

curl -s -H "Client: Get-Duration" -D /dev/stdout -o /dev/null http://www.yoursite.ca | awk '/^Duration: / {print $2}'

IF your system returns the correct Duration value for rendering the page when you only do a HEAD request, you can simplify this:

curl -s -H "Client: Get-Duration" -I http://www.yoursite.ca | awk '/^Duration: / {print $2}'
share|improve this answer
    
+1, don't reinvent the wheel –  James Sep 24 '09 at 12:50
    
Very true; I once spent a couple of days writing a bash script to do some directory/file parsing, when it turned out that what I should have done was read the manpage for "wc". –  RainyRat Sep 24 '09 at 13:11

I think something like this would work:

#!/bin/sh
timeout=10
tracefile=/tmp/.telnettrace
HOST=$1

telnet_commands() {
   tout=${timeout}
   echo open $1 80

   sleep 1

   while [ "$tout" -ge 0 ]
   do
      if tail -1 $tracefile 2>/dev/null | grep "character" > /dev/null
      then
         echo "GET /index.html HTTP/1.1 Host: myhost.com Client: Get-Duration\n"
         tout=-15
         continue
      else
         sleep 1
         tout=$[$tout-1]
      fi
   done
   tout=${timeout}
   while [ "$tout" -ge 0 ]
   do
      if tail -1 $tracefile 2>/dev/null | grep  "^$" > /dev/null
      then
         tout=-15
         continue
      else
         sleep 1
         tout=$[$tout-1]
      fi
   done
}

telnet_commands $HOST | telnet |tee $tracefile
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.