-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathexternalip-benchmark
executable file
·70 lines (60 loc) · 1.72 KB
/
externalip-benchmark
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# tests the speed of various services for externalip:
# https://github.com/rsp/scripts/blob/master/externalip.md
# converted from the ajax-cdn-speed-test:
# https://github.com/rsp/ajax-cdn-speed-test
# by Rafał Pocztarski https://rsp.github.io/
# hosts taken on 2015-04-02 from:
# http://unix.stackexchange.com/questions/22615
# https://coderwall.com/p/lyrjsq/extract-your-external-ip-using-command-line-tools
# using only those that output IP only (with no need to parse output)
read -d '' urls << 'END'
//ifconfig.me/
//icanhazip.com/
//ip.appspot.com/
//curlmyip.com/
//ident.me/
//tnx.nl/ip
//ipecho.net/plain
//whatismyip.akamai.com/
//wgetip.com/
//ip.tyk.nu/
//curlmyip.com/
//corz.org/ip
//bot.whatismyipaddress.com/
//ifcfg.me/
//ipof.in/txt
//l2.io/ip
//eth0.me/
END
pings=5
interval=0.2
httpl=
httpsl=
pingl=
for url in $urls
do
echo -e "\n$url"
for protocol in http https
do
purl="$protocol:$url"
cout=$(curl -m10 -L -sw "~over $protocol:\t%{time_total}s\n" $purl | tr -d '\n')
echo $cout
answer=$(echo $cout | cut -d'~' -f1)
stats=$(echo $cout | cut -d'~' -f1)
time=$(echo $cout | awk '{print $NF; exit}')
[ $protocol = http ] && httpl="$httpl$time http:$url - answer='$answer'\n"
[ $protocol = https ] && httpsl="$httpsl$time https:$url - answer='$answer'\n"
done
host=`echo $url | cut -d/ -f3`
avgping=`ping -c $pings -i $interval $host | tail -1 | cut -d/ -f 5`
[ -z "$avgping" ] && avgping=999999
echo -e "average ping:\t$avgping"
pingl="$pingl$avgping $url\n"
done
echo -e "\nBest http response times:"
echo -e "$httpl" | sort -n
echo -e "\nBest https response times:"
echo -e "$httpsl" | sort -n
echo -e "\nBest average ping times:"
echo -e "$pingl" | sort -n