#!/usr/bin/perl # Draw graphs of HTTP transactions from http-stats output # (c) 2003 Martin Mares , GPL'ed use strict; use warnings; use POSIX; my $datafile = "gp.tmp"; open D, ">$datafile" or die; my @colnames = (); my @ewma = ( 0, 0, 0 ); my $ew = 0.9; my $eww = 1-$ew; while (<>) { chomp; if (/^#/) { s/^#\s+//; @colnames = split /\t/; } else { my $i = 0; s/\([^)]*\)//g; my %row = map { $colnames[$i++] => $_ } split /\t/; my $time = POSIX::strftime("%d-%m-%Y %H:%M:%S", localtime $row{'time'}); my $w = $row{'width'}; my @r = ( $row{'Total'} / $w, $row{'TCPErr'} / $w, ($row{'Total'} - $row{'NTimings'}) / $w ); print D "$time"; for (my $i=0; $i<=$#r; $i++) { $ewma[$i] = $ew*$ewma[$i] + $eww*$r[$i]; print D "\t", $ewma[$i]; } print D "\n"; } } close D; open GP, "|gnuplot" or die; print GP <