Created
March 26, 2014 03:30
-
-
Save KylePDavis/9776517 to your computer and use it in GitHub Desktop.
Revisions
-
KylePDavis created this gist
Mar 26, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #!/bin/bash # A simple script to get the given URL with cURL and output stats. # # USAGE: # get_url_stats.sh <URL> # ############################################################################### out() { echo "`date +%Y%m%dT%H%M%SZ`: $*"; } err() { out "$*" 1>&2; } die() { err "EXIT: $1" && [ "$2" ] && [ "$2" -gte 0 ] && exit $2 || exit 1; } usage() { [ "$0" = "bash" ] || sed '2,/^##/p;d' "$0"; echo "$*"; exit 1; } [ "$1" = "--help" -o "$1" = "-h" ] && usage [ "$1" ] || usage [ "$FIELDS" ] || FIELDS=" http_code http_connect num_connects num_redirects size_download size_header size_request size_upload speed_download speed_upload time_appconnect time_connect time_namelookup time_pretransfer time_redirect time_starttransfer time_total " FORMAT_STR="$(echo "$FIELDS" | egrep '^[a-z]' | awk '{print $1}' | sed 's/.*/&:%{&}/' | paste -sd ' ')\\n" exec curl -s -k -L -o/dev/null -w "$FORMAT_STR" "$@"