Skip to content

Instantly share code, notes, and snippets.

@andresvia
Created July 22, 2016 21:28
Show Gist options
  • Save andresvia/ef84139eb45e8822df0a674e0af8ed14 to your computer and use it in GitHub Desktop.
Save andresvia/ef84139eb45e8822df0a674e0af8ed14 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
count="$1"
test_name="$2"
dns_server="$3"
total=0
for (( i = 0 ; i <= count ; i++ ))
{
now="$(date +%s)"
dig="$(dig +short "${test_name}" "@${dns_server}")"
dig="${dig:-NONE}"
then="$(date +%s)"
elapsed="$((then-now))"
total="$((total+elapsed))"
echo $now,$dig,$elapsed
}
bc -l <<< "scale = 2;${total} / ${count}" > /dev/stderr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment