Investigate HTTP response times
I was investigating some odd behaviour on Smokeping and I wanted a quick way of finding HTTP response times for each step of the route.
I put together this bash script that does a Curl on a given Host/IP and returns the time to connect, the transfer start time, and the total response time.
#!/bin/bash
CURL="/usr/bin/curl"
echo -n "Enter Url to test: "
read url
URL="$url"
result=`$CURL -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
IFS=':' read -a times <<< "${result}"
echo "Results: $URL"
echo "------------------------------------------------"
echo "| Connect Time | Transfer Start Time | Total |"
echo "------------------------------------------------"
echo "| ${times[0]}ms | ${times[1]}ms | ${times[2]}ms |"
echo "------------------------------------------------"
Please feel free to use, improvement suggestions are welcome.
Written by adamstrawson
Related protips
2 Responses
hey, use the bash script, no time output.
Enter Url to test: http://baidu.com
Results: http://baidu.com
| Connect Time | Transfer Start Time | Total |
| ms | ms | ms |
over 1 year ago
·
Hey David,
Sorry, there was a typo on one of the variables
Change:
IFS=':' read -a time <<< "${result}
To:
IFS=':' read -a times <<< "${result}
Cheers,
Adam
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Http
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#