Show size_vs_time.pl syntax highlighted
#!/usr/bin/perl -w
use strict;
use Date::Parse;
use Getopt::Long;
use Pod::Usage;
use IO::File;
Getopt::Long::Configure ("bundling");
our $HELP = 0;
our $MAN = 0;
our $DEBUG = 0;
our $START = '2005/1/1 01:00';
our $END = '2020/1/1 01:00';
our $FRAMETIME_SECONDS = 24*3600; # Default of 1 day per frame
GetOptions("help|h" => \$HELP,
"man" => \$MAN,
"start|s=s" => \$START,
"end|e=s" => \$END,
"animate|a=i" => \$FRAMETIME_SECONDS,
) or pod2usage(2);
pod2usage(-exitstatus => 0, -verbose => 1) if $HELP;
pod2usage(-exitstatus => 0, -verbose => 2) if $MAN;
my $begintime = str2time($START);
my $endtime = str2time($END);
my @times;
my $resp;
my $msgcnt;
my $cresp;
my $n = 0;
$" = " ";
my ($start, $end);
our $frame = 0;
our @histtimes;
our $DATA = new IO::File;
my $nextframetime = $begintime;
sub nextFrame
{
my $time = shift;
if($frame) {
push @histtimes, $time;
}
close($DATA) if $DATA;;
$frame++;
open($DATA, sprintf(">stats%05d.dat", $frame));
}
my $pagepattern = 'Index.* size: (\d+) .*Page Processing Time.* ([.0-9]+)\D';
my ($curtime, $ts);
while(<>)
{
next if !m/$pagepattern/o;
($start) = m/(\d+\/\d+\/\d+ \d+:\d+:\d+)/ if(!defined($start));
($ts) = m/(\d+\/\d+\/\d+ \d+:\d+:\d+)/;
$curtime = str2time($ts);
if($curtime > $nextframetime) {
$nextframetime = $curtime + $FRAMETIME_SECONDS;
nextFrame($ts);
print "Starting frame $frame\n";
}
if($curtime < $begintime || $curtime > $endtime) {
$start = undef if($curtime < $begintime);
if(!defined($end) && $curtime >= $endtime) {
$end = $ts;
last;
}
next;
}
@times = m/$pagepattern/o;
$n++;
$msgcnt = $times[0];
$cresp = $times[1];
print $DATA "$msgcnt $cresp\n";
}
nextFrame($ts);
close($DATA);
$end = $ts if(!defined($end));
die "No data in range" if !$n;
my $pagename = "index.html";
open CMDS, ">/tmp/stats.cmds";
print CMDS <<EOF;
set terminal postscript color
set title "Response time Histogram for $pagename from $start to $end"
set xlabel "Folder Size (messages)"
set ylabel "Response Time (s)"
set yrange [0:10]
set output "stats.ps"
EOF
for(my $i=1; $i <= $frame; $i++) {
print CMDS "plot " . sprintf("\"stats%05d.dat\"", $i) .
" title \"" . $histtimes[$i-1] . "\"\n";
}
qx(gnuplot /tmp/stats.cmds);
warn "Unable to create plot. Gnuplot failed." if(!-f "stats.ps");
qx(ps2pdf stats.ps stats.pdf);
warn "Unable to create PDF. PS missing or ps2pdf failed" if(!-f "stats.pdf");
unlink "stats.ps";
unlink "/tmp/stats.cmds";
print "Histogram data in stats.pdf\n" if(-f "stats.pdf");
exit 0;
__END__
=head1 NAME
size_vs_time.pl - Analyze folder size against response time.
=head1 SYNOPSIS
size_vs_time.pl [--help] [--man] [--start|-s start] [--end|-e end] [--animate|-a framelength_seconds] logfile ...
=head1 OPTIONS
=over 8
=item B<--help, -h>
Show command help.
=item B<--man>
Show the complete manual for the command.
=item B<--start=start | -s start>
Specify the exact time and date from which to start the analysis. Accepts
timestamps in any format parsable by Date::Parse.
=item B<--end=start | -e start>
Specify the exact time and date at which to end the analysis. Accepts
timestamps in any format parsable by Date::Parse.
=item B<--animate=n | -a n>
Indicate that you want a multipage "animation" of the response times, with one
frame/page every n seconds.
=back
=head1 DESCRIPTION
B<size_vs_time.pl> will read your alphamail log file and use it to
create a scatter plot of folder size vs. response time.
It defaults to generating one page per 24 hours of data, but the -a parameter
can be used to change this "frame" rate in order to make interesting
"animations" of your response time.
=cut
See more files for this project here
AlphaMail is an accelerated web mail interface with a C++ middleware layer that is more effective than an IMAP proxy which is a highly scalable (10k+ users). The interface includes modern features, Section 508 compliance, and universal browser support.
Project homepage:
http://sourceforge.net/projects/alphamail
Programming language(s): C++,Java,JavaScript,Perl
License: other
init.d/
alphamail_tmpfs
imap_webcache
sandbox/
Makefile.am
sandbox.cc
Makefile.am
alphamail_genconfig
alphamail_stats
awstats_gen
garbage_sweeper
hang_detector
logrotate.conf
prefs_depth.pl
size_vs_time.pl
update_prefs
webcache_watcher