]> mj.ucw.cz Git - netgrind.git/blob - post/graph-http-spect-sizes
Implemented dumping of HTTP transactions
[netgrind.git] / post / graph-http-spect-sizes
1 #!/usr/bin/perl
2 # Draw spectrum of HTTP transaction lengths from netgrind output
3 # (c) 2003 Martin Mares <mj@ucw.cz>, GPL'ed
4
5 use strict;
6 use warnings;
7 use POSIX;
8
9 my @k = ( 0, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 1000000000 );
10 my @v = map { 0 } @k;
11
12 while (<>) {
13         chomp;
14         /^#/ && next;
15         my ($t1, $t2, $src, $dst, $ffor, $result, $cache, $queue, $length, $totaltime, $waittime, $ctype, $method, $url) = split /\s+/;
16         if ($result =~ /^\d+$/) {
17                 my $i = 0;
18                 while ($length >= $k[$i+1]) {
19                         $i++;
20                 }
21                 $v[$i]++;
22         }
23 }
24
25 my $datafile = "gp.tmp";
26 open D, ">$datafile" or die;
27 for(my $i=0; $i<$#k; $i++) {
28         print D $k[$i], "\t", $v[$i], "\n";
29 }
30 close D;
31
32 open GP, "|gnuplot" or die;
33 print GP <<EOF
34 set terminal png
35 set grid
36 set style data boxes
37 set title "HTTP Transactions: Length Histogram"
38 set xlabel "Length in bytes"
39 set ylabel "Number of transactions"
40 set logscale x 2
41 plot    "$datafile" using 1:2 title "Histogram"
42 EOF
43 ;
44 close GP;