#!/bin/bash # Copyright (c) Michael Still 2001, released under the terms of the GNU GPL start=`ls unclassified | wc -l | tr -d " "` for host in `ls unclassified | sed 's/unclassified\///'` do echo -n "$host " # It would seem we can't use waitsecs (-w) to terminate ping, because this simply doesn't work! (sleep 5; killall ping 2> /dev/null) & if [ `ping -c 1 $host | grep "0% packet loss" | wc -l | tr -d " "` -gt 0 ] then echo -n "[ping ok] " routepath=routes lost=no # Reduce the number of hops for a traceroute, on the assumption that things within the ISE LAN # can't be too far away. Otherwise a timeout on a 30 hop traceroute to a not responing machine # takes _ages_ for routeline in `/usr/sbin/traceroute -n -m 5 $host 2> /dev/null | tr " " "~" | tr -s "~"` do routehost=`echo $routeline | cut -f 3 -d "~"` echo -n "($routehost) " if [ "$routehost" = '*' ] then if [ $lost = "no" ] then routehost=tracelost echo -n " " lost="$routepath/tracelost" else echo -n " " routehost="" fi fi routepath="$routepath/$routehost" mkdir -p $routepath done if [ $lost = "no" ] then mv unclassified/$host $routepath/$host-info else cp unclassified/$host $lost/$host-info fi echo -n " " else echo -n "[ping failed] " fi done echo "Traced" $(( `ls unclassified | wc -l | tr -d " "` - $start )) "hosts"