From: Michael Tremer Date: Wed, 25 Feb 2009 12:56:54 +0000 (+0000) Subject: Added a tool to check distcc hosts. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=632eb1d06e22c5fd0e6cd73903873f53cfd64fa7;p=ipfire-3.x.git Added a tool to check distcc hosts. --- diff --git a/tools/make-compilers b/tools/make-compilers index 4400b9da1..ea0bf1286 100755 --- a/tools/make-compilers +++ b/tools/make-compilers @@ -102,7 +102,37 @@ distcc_get_hosts() { logger --distcc "[INFO] Got host: $i" echo "$i" >> $BASEDIR/distcc/hosts_new done - [ -s "$BASEDIR/distcc/hosts_new" ] && mv -f $BASEDIR/distcc/hosts{_new,} + [ -s "$BASEDIR/distcc/hosts_new" ] && cat $BASEDIR/distcc/hosts_new | \ + distcc_test_hosts > $BASEDIR/distcc/hosts +} + +distcc_test_hosts() { + while read i; do + if [ "${i}" = "localhost" ] || [ "${i:0:2}" = "--" ]; then + echo ${i} + continue + fi + + i=${i%,lzo} + host=$(awk -F: '{ print $1 }' <<<${i}) + jobs=${i##*/} + port=$(awk -F: '{ print $2 }' <<<${i} | awk -F/ '{ print $1 }') + ip=$($BASEDIR/tools/resolver $host) + + if ping -c3 -w5 ${ip} &>/dev/null; then + if [ -n "$(which netcat)" ]; then + if (echo | netcat -w 5 ${ip} ${port} 2>/dev/null); then + echo "${ip}:${port}/${jobs},lzo # ${host}" + else + echo "# Host $host ($ip) is reachable but distcc does not respond." + fi + continue + fi + echo "${ip}:${port}/${jobs},lzo # ${host}" + else + echo "# Host $host ($ip) is not reachable." + fi + done } distcc_reload() { diff --git a/tools/resolver b/tools/resolver new file mode 100755 index 000000000..8b7fa6cea --- /dev/null +++ b/tools/resolver @@ -0,0 +1,6 @@ +#!/usr/bin/python + +import sys +import socket + +print socket.gethostbyname(sys.argv[1])