msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

31 Mar 15 Monitoring latency time of http requests

Here is a simple but useful command which shows the latency time of http requests. You can adjust the delay between repeats as well as the URL being queried.
Reference: //www.shellhacks.com/en/Check-a-Website-Response-Time-from-the-Linux-Command-Line

host="www.google.de"; delay=5; while true ; do echo -n "Response time for //$host:" ;curl -s -w %{time_total}\\n -o /dev/null //$host ;sleep $delay; done

Results:
Response time for //www.google.de:0,025
Response time for //www.google.de:0,024
Response time for //www.google.de:0,024
Response time for //www.google.de:0,024
Response time for //www.google.de:0,024
Response time for //www.google.de:0,026
Response time for //www.google.de:0,024
Response time for //www.google.de:0,024
Response time for //www.google.de:0,024
.......

ADVANCED:
Here is a more advance version which performs more timing tests:

host="www.google.de"; delay=5; while true ; do echo "------"; curl -s -w '\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null //$host; sleep $delay; done

Results:
Lookup time: 0,002
Connect time: 0,011
PreXfer time: 0,011
StartXfer time: 0,022
.
Total time: 0,023
------
.
Lookup time: 0,001
Connect time: 0,012
PreXfer time: 0,013
StartXfer time: 0,023
.
Total time: 0,023
------
.......

Meanings:
Lookup time: The time, in seconds, it took from the start until the name resolving was completed.
Connect time: The time, in seconds, it took from the start until the TCP connect to the remote host was completed.
PreXfer time: The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all ‘pre-transfer’ commands and negotiations that are specific to the particular protocol(s) involved.
StartXfer time: The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes ‘time_pretransfer’ and also the time the server needed to calculate the result.

Reader's Comments

  1.    

    Thank you so much, Michel, for putting this together.
    It’s so beautiful and handy.
    I changed a bit to check https like this:

    host=”servicedesk.lsrsupport.com”; delay=5; while true ; do echo “——“; curl -s -w ‘\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n’ -o /dev/null //$host; sleep $delay; done

    It works just like chime.

    Regards,

    Alex

    Reply to this comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: