![]() |
![]()
| ![]() |
![]()
NAMETail::Stat::Plugin - Abstract plugin class SYNOPSISpackage 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; } METHODSnewPlugin instance constructor. Usually you don't need to override it's default behavior. regexAccessor to main regular expression. Called once during initialization (from constructor). init_zone($zone,\%public,\%private,\%window)Called once on zone creating. Usually you can assigns some default values in public statistics. process_line($line)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. process_data(\@ref,\%public,\%private,\%window)Receives reference to array of captured values and modify public, private or current window statistics. process_window(\%public,\%private,\@windows)Called during closing current window. Common usage is calculate averages from complete windows and save results in public or private statistics. process_timer($name,\%public,\%private,\@windows)Processing named timer. Receives timer name and zone statistics. Timer will be renewed unless handler returns false value. dump_zone($zone,\%public,\%private,\@windows)Stringify accumulated statistics. stats_zone($zone,\%public,\%private,\@windows)Optionally preprocess, and stringify accumulated statistics. parse_errorReturns default logging level for unparsed lines. AUTHOROleg A. Mamontov, "<oleg@mamontov.net>" COPYRIGHTThis 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.
|