#!/usr/bin/perl # # pf-savelog-mysql.pl - parse Postfix log and store entries into database (e.g. MySQL) # # Developed by Lubomir Host 'rajo' # Copyright (c) 2004-2005 Platon SDG, http://platon.sk/ # Licensed under terms of GNU General Public License. # All rights reserved. # # Changelog: # 2004-10-19 - created # # $Platon: scripts/perl/postfix/pf-savelog-mysql.pl,v 1.5 2005/09/16 21:29:28 rajo Exp $ use strict; use FindBin; use lib "$FindBin::Bin/../../../perl-modules"; use lib "$FindBin::Bin/perl-modules"; use Platon::Log::Mail::Postfix; use vars qw($VERSION $DEBUG); use vars qw ( $conf ); $VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/); $DEBUG = 0 unless defined $DEBUG; $\ = "\n"; $| = 1; $conf = undef; # use defaults from Platon::Mail.pm my $log = Platon::Log::Mail::Postfix->new($conf); print STDERR "# Platon::Log::Mail::Postfix.pm module version " . $log->version; my $nr = 0; while (my $line = ) { chomp $line; $nr++; $log->savelog($line) or print STDERR "Error saving log entry #$nr: '$line'"; } # IMPORTANT, otherwise you can lose some data $log->flush(); # vim: ts=4 # vim600: fdm=marker fdl=0 fdc=3