Skip to content

Instantly share code, notes, and snippets.

@pgrandin
Created January 14, 2014 23:10
Show Gist options
  • Save pgrandin/8427789 to your computer and use it in GitHub Desktop.
Save pgrandin/8427789 to your computer and use it in GitHub Desktop.
time_api
#!/bin/bash
[ -f /usr/bin/nc.openbsd ] || ACCEPT_KEYWORDS=~amd64 emerge -q openbsd-netcat
url="http://169.254.169.254/2008-02-01/meta-data/public-ipv4"
if [[ "$1" == "-n" ]]; then
url="http://169.254.169.254/openstack/latest/meta_data.json"
fi
PORT=2003
SERVER=172.16.128.252
while true; do
START_TIME=$SECONDS
for i in `seq 1 10`; do
wget -q -O - $url > /dev/null
done
t=$(($SECONDS - $START_TIME))
printf "\r$t "
echo "local.ec2_api_response_time $t `date +%s`" | nc.openbsd ${SERVER} ${PORT};
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment