Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Pondelok, 22. júl 2024

Súbor: [Platon] / scripts / perl / postfix / pf-savelog-mysql.pl (stiahnutie)

Revízia 1.6, Sun Dec 4 21:33:24 2005 UTC (18 years, 7 months ago) by rajo


Zmeny od 1.5: +4 -2 [lines]

Implemented "cache" feature. Speed improvements 39%.

#!/usr/bin/perl

#
# pf-savelog-mysql.pl - parse Postfix log and store entries into database (e.g. MySQL)
#
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk>
# 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 = <STDIN>) {
    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


Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok