| Revision 30 (by dpavlin, 2003/11/19 14:15:09) |
produce dot file (for graphviz) from traceroute output. Very useful to
compare traceroutes from different parts of world to your server.
|
#!/usr/bin/perl -w
# convert one or more traceroute dumps to nice graphviz graph (with colors
# and everything)
#
# You should really name files as hostnames from which this traceroute
# is taken (it will be used as first node in traceroute)
#
# e.g. ssh izuh traceroute mjesec.ffzg.hr > izuh
#
# Dobrica Pavlinusic <dpavlin@rot13.org> 2003-11-18
use strict;
print qq(
digraph dns {
// rankdir=LR;
edge [ fontname = "trebuc", fontsize=9 ]
node [ fontname = "trebuc", fontsize=10 ]
);
my @colors = qw(#FF99CC #FFCC99 #FFFF99 #CCFFCC #99CCFF #CC99FF);
my $col = 0; # color index
foreach my $file (@ARGV) {
open(T,$file) || die "can't open $file: $!";
my $from = $file;
while(<T>) {
chomp;
s/^\s*//;
next if (! m/^\d+/);
my ($nr,$host,$ip,$time,$unit,undef) = split(/\s+/,$_,6);
$time .= " $unit";
print qq{ "$from" -> "$host" [ label="$nr: $time", color="$colors[$col]" ] \n};
$from = $host;
}
$col++;
$col = 0 if ($col > $#colors);
}
print qq(});