Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created August 19, 2016 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahemoff/72868c283c3aa657c633d2d720925702 to your computer and use it in GitHub Desktop.
Save mahemoff/72868c283c3aa657c633d2d720925702 to your computer and use it in GitHub Desktop.
# WEB
# e.g. webcheck /about google.com google.co.uk
# will check each host in parallel, multiple times
function webcheck {
trap handle_sigint SIGINT
set +m
path=$1
shift
hosts=$*
for host in $hosts ; do
(
url="$host$path"
message="$url\n"
for i in {1..5}; do
start=`ruby -e 'puts Time.now.to_f'`
result=$(curl --silent -I $url | head -1)
end=`ruby -e 'puts Time.now.to_f'`
duration=$(bc <<< "$end-$start")
message="$message$i. $duration -> $result\n"
done
printf "$message\n"
) &
done 2>/dev/null
wait
}
# http://stackoverflow.com/a/7817949/18706
function handle_sigint() {
for proc in `jobs -p` ; do kill $proc ; done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment