1 |
#!/usr/bin/perl -w |
2 |
|
3 |
# convert one or more traceroute dumps to nice graphviz graph (with colors |
4 |
# and everything) |
5 |
# |
6 |
# You should really name files as hostnames from which this traceroute |
7 |
# is taken (it will be used as first node in traceroute) |
8 |
# |
9 |
# e.g. ssh izuh traceroute mjesec.ffzg.hr > izuh |
10 |
# |
11 |
# Dobrica Pavlinusic <dpavlin@rot13.org> 2003-11-18 |
12 |
|
13 |
use strict; |
14 |
|
15 |
print qq( |
16 |
|
17 |
digraph dns { |
18 |
|
19 |
// rankdir=LR; |
20 |
|
21 |
edge [ fontname = "trebuc", fontsize=9 ] |
22 |
node [ fontname = "trebuc", fontsize=10 ] |
23 |
|
24 |
); |
25 |
|
26 |
my @colors = qw(#FF99CC #FFCC99 #FFFF99 #CCFFCC #99CCFF #CC99FF); |
27 |
my $col = 0; # color index |
28 |
|
29 |
foreach my $file (@ARGV) { |
30 |
open(T,$file) || die "can't open $file: $!"; |
31 |
my $from = $file; |
32 |
while(<T>) { |
33 |
chomp; |
34 |
s/^\s*//; |
35 |
next if (! m/^\d+/); |
36 |
my ($nr,$host,$ip,$time,$unit,undef) = split(/\s+/,$_,6); |
37 |
$time .= " $unit"; |
38 |
print qq{ "$from" -> "$host" [ label="$nr: $time", color="$colors[$col]" ] \n}; |
39 |
$from = $host; |
40 |
} |
41 |
$col++; |
42 |
$col = 0 if ($col > $#colors); |
43 |
} |
44 |
|
45 |
print qq(}); |