#!/usr/bin/perl # Calculate statistics of HTTP transactions from netgrind output # (c) 2003 Martin Mares , GPL'ed use strict; use warnings; use POSIX; print "# time width Total TCPErr Nocache CacheHit CacheMiss LenTotal NTimings TimeTotal TimeTMin TimeTMax TimeWait TimeWMin TimeWMax NGETs NPOSTs\n"; my $histogran = 60; my %hist = (); while (<>) { chomp; /^#/ && next; my ($t1, $t2, $src, $dst, $ffor, $result, $cache, $queue, $length, $totaltime, $waittime, $ctype, $method, $url) = split /\s+/; my ($tY, $tm, $td) = split (/-/, $t1); my ($tH, $tM, $tS) = split (/:/, $t2); my $tt = POSIX::mktime($tS, $tM, $tH, $td, $tm-1, $tY-1900); $tt -= $tt % $histogran; my $h = $hist{$tt}; if (!defined $h) { $h = [ $histogran, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000, 0, 0, 1000000000, 0, 0, 0 ]; $hist{$tt} = $h; } $h->[1]++; $h->[2]++ if $result =~ /^[TC]/; $h->[3]++ if $cache =~ /^((N..)|(.[NP].))$/; $h->[4]++ if $cache =~ /\+$/; $h->[5]++ if $cache =~ /-$/; $h->[6]+=$length; if ($result =~ /^\d+$/) { $h->[7]++; $h->[8]+=$totaltime; $h->[9]=$totaltime if $h->[9] > $totaltime; $h->[10]=$totaltime if $h->[9] < $totaltime; $h->[11]+=$waittime; $h->[12]=$waittime if $h->[12] > $waittime; $h->[13]=$waittime if $h->[12] < $waittime; } $h->[14]++ if $method eq "GET"; $h->[15]++ if $method eq "POST"; } foreach my $x (sort keys %hist) { print "$x\t", join("\t", @{$hist{$x}}), "\n"; }