2 # Draw graphs of link traffic from netgrind histograms
3 # (c) 2003 Martin Mares <mj@ucw.cz>, GPL'ed
9 my $datafile = "gp.tmp";
10 open D, ">$datafile" or die;
13 my @ewma = ( 0, 0, 0 );
21 @colnames = split /\t/;
24 my %row = map { $colnames[$i++] => $_ } split /\t/;
25 my $time = POSIX::strftime("%d-%m-%Y %H:%M:%S", localtime $row{'time'});
26 my $linkin = $row{'LinkIn'};
27 $linkin =~ s/.*\((.*)\)/$1/;
28 my $ipin = $row{'IPIn'};
29 $ipin =~ s/.*\((.*)\)/$1/;
31 $linkin * 8 / $w / 1024,
34 $r[1] = $r[0] - $r[1];
36 for (my $i=0; $i<=$#r; $i++) {
37 $ewma[$i] = $ew*$ewma[$i] + $eww*$r[$i];
38 print D "\t", $ewma[$i];
45 open GP, "|gnuplot" or die;
50 set title "Captured traffic"
52 set ylabel "Kbit/s [EWMA $ew]"
54 set timefmt "%d-%m-%Y %H:%M:%S"
55 set format x "%d/%m\\n%H:%M"
58 plot "$datafile" using 1:3 title "Total traffic", \\
59 "$datafile" using 1:4 title "Non-IP traffic"