#!/usr/bin/perl # Draw graphs of HTTP transaction delays from http-stats output # (c) 2003 Martin Mares , GPL'ed use strict; use warnings; use POSIX; my $maxs = (@ARGV >= 1 && $ARGV[0] eq "--max"); my $datafile = "gp.tmp"; open D, ">$datafile" or die; my @colnames = (); my @ewma = ( 0, 0, 0, 0, 0, 0 ); my $ew = 0; 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 $n = $row{'NTimings'}; my @r; if ($n) { @r = ( $row{'TimeTotal'} / $n, $row{'TimeTMin'}, $row{'TimeTMax'}, $row{'TimeWait'} / $n, $row{'TimeWMin'}, $row{'TimeWMax'} ); } else { @r = ( 0, 0, 0, 0, 0, 0 ); } 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; my $ct = $maxs ? "Maximum" : "Average"; my $c1 = $maxs ? 5 : 3; my $c2 = $maxs ? 8 : 6; open GP, "|gnuplot" or die; print GP <