]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Added a tool to check distcc hosts.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 25 Feb 2009 12:56:54 +0000 (12:56 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 25 Feb 2009 12:56:54 +0000 (12:56 +0000)
tools/make-compilers
tools/resolver [new file with mode: 0755]

index 4400b9da1839acee57c8c44ef7f27042e1a4dc90..ea0bf12862ba0088432422155bec1de4f4c49397 100755 (executable)
@@ -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 (executable)
index 0000000..8b7fa6c
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/python
+
+import sys
+import socket
+
+print socket.gethostbyname(sys.argv[1])