Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions dnstest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DOMAINS2TEST="www.google.com amazon.com facebook.com www.youtube.com www.reddit.


totaldomains=0
result=2000000
printf "%-18s" ""
for d in $DOMAINS2TEST; do
totaldomains=$((totaldomains + 1))
Expand All @@ -45,19 +46,29 @@ for p in $NAMESERVERS $PROVIDERS; do
for d in $DOMAINS2TEST; do
ttime=`$dig +tries=1 +time=2 +stats @$pip $d |grep "Query time:" | cut -d : -f 2- | cut -d " " -f 2`
if [ -z "$ttime" ]; then
#let's have time out be 1s = 1000ms
ttime=1000
#let's have time out be 1s = 1000ms
ttime=1000
elif [ "x$ttime" = "x0" ]; then
ttime=1
fi
ttime=1
fi

printf "%-8s" "$ttime ms"
ftime=$((ftime + ttime))
done
avg=`bc -lq <<< "scale=2; $ftime/$totaldomains"`

echo " $avg"
n1=$(echo $avg | cut -d"." -f 1)
n2=$(echo $avg | cut -d"." -f 2)
nf=$(echo "$n1$n2")
if [[ "$nf" -lt "$result" ]]; then
timer=$avg
result=$nf
winner=$pname
fi
done

echo ""
echo "## The Winner is $winner with a time of $timer ##"

exit 0;