Created
January 26, 2018 05:43
-
-
Save aerostitch/10896b5303c25d04a81032fefa7160f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script's purpose is to test the response time on a url | |
# by doing a simple curl loop (no pause, so a bit hammering). | |
# It returns the several curl metrics in a csv file for further analysis. | |
# | |
TO="localhost" | |
OUTFILE="$(date +%Y%m%d%H%M)_curl_test_from_$(hostname)_to_${TO}.csv" | |
CURLURI="http://${TO}/crossdomain.xml" | |
CURLFORMAT='\n%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total},%{num_connects},%{num_redirects}' | |
ITERATIONS=100000 | |
# Header | |
echo -e "$(date +%F): Testing url ${CURLURI} from $(hostname)" > $OUTFILE | |
echo -e "Date,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer,time_total,num_connects,num_redirects" >> $OUTFILE | |
i=0 | |
while [ $i -lt $ITERATIONS ] | |
do | |
curl -w "${CURLFORMAT}" -o /dev/null -s $CURLURI | xargs echo -e "$(date +%H:%M:%S.%6N)," >> $OUTFILE | |
i=$[$i+1] | |
done | |
# vim: set nowrap: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment