Tail::Stat::Plugin - Abstract plugin class
package Tail::Stat::Plugin::apache;
use strict;
use warnings qw(all);
use base qw(Tail::Stat::Plugin);
sub regex { qr/^(\d+)\s+(\d+)/ }
sub process_data {
my ($self,$lref,$pub,$win) = @_;
$pub->{param1} += $lref->[0];
$win->{param2} += $lref->[1];
$win->{count}++;
}
sub process_window {
my ($self,$pub,$prv,$wins) = @_;
$pub->{last_param2} = sum ( map { $_->{param2} || 0 } @$wins ) || 0;
}
Plugin instance constructor. Usually you don't need to override it's default
behavior.
Accessor to main regular expression. Called once during initialization (from
constructor).
Called once on zone creating. Usually you can assigns some default values in
public statistics.
Parse single log line and returns array of successfully captured values. Method
must returns true value in scalar context, otherwise message will be logged
about unprocessed line.
Receives reference to array of captured values and modify public, private or
current window statistics.
Called during closing current window. Common usage is calculate averages from
complete windows and save results in public or private statistics.
Processing named timer. Receives timer name and zone statistics. Timer will be
renewed unless handler returns false value.
Stringify accumulated statistics.
Optionally preprocess, and stringify accumulated statistics.
Returns default logging level for unparsed lines.
Oleg A. Mamontov, "<oleg@mamontov.net>"
This program is free software; you can redistribute it and/or modify it under
the terms of either: the GNU General Public License as published by the Free
Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.