Simple sh script to find most appropriate POP
Shadow Hawkins on Tuesday, 09 November 2004 16:32:04
#!/bin/bash
#Point of Presence list
POPS="eetll01.sixxs.net fihel01.sixxs.net deham01.sixxs.net demuc02.sixxs.net iedub01.sixxs.net ittrn01.sixxs.net nlede01.sixxs.net nlams01.sixxs.net nlams04.sixxs.net nlams05.sixxs.net gblon01.sixxs.net"
IFS=$' '
min_ping=10000
min_pop=''
function probe_ping
{
for pop in $POPS
do
printf "Pinging %-15s ..." $pop
ping=`ping -w 5 $pop | grep "rtt min/avg/max/mdev" | cut -d'/' -f5 | cut -d'.' -f 1`
if [ -z $ping ]
then
echo "N/A"
else
if [ $ping -lt $min_ping ]
then
min_ping=$ping
min_pop=$pop
fi
echo "$ping ms"
fi
done
if [ $min_ping -eq 100000 ]
then
echo "Ping probe failed, aborting."
exit 1
else
echo "Minimum ping time is $min_ping ms from $min_pop"
fi
}
if [ $UID -ne 0 ]
then
echo "You aren't root, pinging only..."
probe_ping
else
probe_ping
#configure........
fi
exit 0
Posting is only allowed when you are logged in. |