1 |
Here's a quick script to allow one to determine the distance between a |
2 |
'client' and either one or several servers. Theoretically, the fewer the |
3 |
number of 'hops' between two devices on internet, the fewer the number of BGP |
4 |
sessions, the lower the number of places 'things can go wrong', the lower the |
5 |
latency, the faster the throughput. |
6 |
|
7 |
Written in shell... mtr can be interchanged with traceroute, tcptraceroute, |
8 |
etc. Use as ye see fit. |
9 |
|
10 |
--- CUT HERE --- |
11 |
# AUTHOR: gaarde at users dot sourceforge dot net |
12 |
# Licence: GPL-2 |
13 |
|
14 |
# Trace to a server and find it's "distance" from us |
15 |
function sroute () { |
16 |
route_len=`/usr/sbin/mtr -rc 1 $1 2> /dev/null | wc -l`; |
17 |
printf "%-2d %s\n" $route_len $1 |
18 |
} |
19 |
|
20 |
# Trace to many servers using sroute and sort the results |
21 |
function sroutes () { |
22 |
for aserver in $*; do |
23 |
sroute $aserver; |
24 |
done | sort --numeric-sort |
25 |
} |
26 |
--- END CUT --- |
27 |
|
28 |
===== |
29 |
--- |
30 |
"To thine own self be true." - Shakespeare |
31 |
|
32 |
__________________________________________________ |
33 |
Do You Yahoo!? |
34 |
Yahoo! Health - Feel better, live better |
35 |
http://health.yahoo.com |