]>
pere.pagekite.me Git - homepage.git/blob - linux/ypserv-closest.sh
3 # Author: Petter Reinholdtsen <pere@hungry.com>
5 # Name: ypserv-closest.sh
7 # Fetch the list of NIS servers from NIS, and list the "closest"
8 # servers (fastest reply) in yp.conf format.
10 # Uses 'ypcat' to find the servers, 'fping' to time the network
11 # distance and normal shell tools to make the list.
16 # fping is in /local/sbin/
17 PATH
="/local/sbin:$PATH"
20 # ypcat on OSF/1 prints 'key value'
21 allservers
=`ypcat ypservers | cut -d" " -f1`
24 # -a = show targets by address
25 # -e = show time elapsed
27 # 129.240.130.23 is alive (0.22 ms)
28 # 129.240.130.21 is alive (0.23 ms)
29 servers
=`fping -A -e $allservers | awk '{print $4,$1}' | cut -d'(' -f2 |
30 sort -n | head -$count | cut -d" " -f2`
32 for server
in $servers; do
33 echo "domain $domain server $server"