/[sysadmin-cookbook]/recepies/netpipe-tcp/np2graphviz.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /recepies/netpipe-tcp/np2graphviz.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 100 - (show annotations)
Mon May 25 22:11:20 2009 UTC (14 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1014 byte(s)
create graphviz dot file

1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 my $graph;
7
8 my ($max,$min);
9
10 foreach my $file ( glob '*/*.np' ) {
11
12 my $direction = $file;
13 $direction =~ s/\.np$//;
14 my ( $from, $to ) = split(m{/},$direction,2);
15
16 my $line = `tail -1 $file`;
17 $line =~ s{^\s+}{};
18 $line =~ s{\s+$}{};
19 my ( $size, $speed, $rtt ) = split(/\s+/, $line);
20
21 warn "$from -> $to | $size | $speed | $rtt\n";
22
23 my $len = int($speed / 100);
24
25 $graph->{ qq|"$from" -> "$to"| } = {
26 size => $size,
27 speed => $speed,
28 rtt => $rtt,
29 };
30
31 $min ||= $speed;
32 $min = $speed if $speed < $min;
33
34 $max ||= $speed;
35 $max = $speed if $speed > $max;
36
37 }
38
39 warn "# speed $min ... $max\n";
40
41 print qq|
42 digraph "netpipe" {
43 |,
44 join("\n", map {
45 my $node = $_;
46 my $speed = $graph->{$_}->{speed};
47 my $c = 'ff0000';
48 $c = '00ff00' if ( $speed / 100 ) > 1;
49 $c = '0000ff' if ( $speed / 1000 ) > 1;
50 $c = '8888ff' if ( $speed / 1000 ) > 2;
51 my $label = $speed;
52 $label =~ s/\.\d+//;
53 qq|$node [ label="$label",color="#$c",len=$speed ]|;
54 } keys %$graph),
55 qq|
56 }
57 |;
58

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26