use strict; use warnings; # process the mail log lines for dkim-filter # Copyright (C) 2011 Glen Pitt-Pladdy # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # # See: http://www.pitt-pladdy.com/blog/_20110615-093433_0100_Universal_Log_Analyser_and_snmpd_extension_scripts/ # package demo; our $VERSION = 20110611; sub register { my ( $lines, $ends ) = @_; push @$lines, \&analyse; push @$ends, \&wrapup; # optional runs after logs done } sub analyse { my ( $line, $number, $log, $stats ) = @_; my $origline = $line; if ( $line !~ s/^.+ demo\[\d+\]:\s*// ) { return; } if ( $line =~ s/^stuff happened:\s*// ) { ++$$stats{'demo:stuffhappened'}; } elsif ( $line =~ s/^more stuff happened:\s*// ) { ++$$stats{'demo:morestuffhappened'}; } else { ++$$stats{'demo:other'}; print STDERR __FILE__." $VERSION:".__LINE__." $log:$number unknown: $origline\n"; } return 1; # it was for us! } sub wrapup { # optional my $stats = shift; # put your own stuff here that needs to run after logs done } \®ister;