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

Súbor: [Platon] / scripts / perl / postfix / README (stiahnutie)

Revízia 1.1, Fri Sep 16 21:29:43 2005 UTC (18 years, 10 months ago) by rajo

Added som documentation.

This is a Perl script, which you can use for parsing log entries from
postfix ( MTA and store into MySQL database. It is
designed for syslog-ng, because syslog-ng is capable log directly to
pipe. But you can run this script from cron etc.


1. Download

Download and also required Perl modules. The best
way is to get fresh CVS version from server, or download
from and

# cvs -d login
# cvs -d co perl-modules
# cvs -d co scripts/perl/postfix

Put perl-modules directory somewhere, where it will be found by script. Directory structure like this should be OK:

# Alternative 1:

# Alternative 2:

2. Configure database connection

Now create and configure your connection to database. Save syslog-ng.cnf
example configuration as /etc/syslog-ng/mysql.conf and set your login
and password for database.

3. Create database tables

# cat db-structure.sql | mysql -u username -h -p

4. Configure syslog-ng

Add following lines to your /etc/syslog-ng/syslog-ng.conf config file.
If you already have syslog-ng configured, you should add only lines
with "dp_mail" keyword:

# all known message sources
source s_all {
        # message generated by Syslog-NG
        # standard Linux log source (this is the default place for the syslog()
        # function to send logs to)
        # messages from the kernel
        file("/proc/kmsg" log_prefix("kernel: "));
        # use the above line if you want to receive remote UDP logging messages
        # (this is equivalent to the "-r" syslogd flag)
        # udp();

# configuration
destination df_mail { file("/var/log/mail/$YEAR-$MONTH-$DAY-mail.log"               template("$ISODATE $HOST [$LEVEL] $MSG\n")); };
destination dp_mail { program("/somewhere/scripts/perl/postfix/" template("$ISODATE $HOST [$LEVEL] $MSG\n")); };
filter f_mail { facility(mail); };

log { 

5. Restart syslog-ng daemon

You should restart your syslog-ng daemon with command:

# /etc/init.d/syslog-ng restart

6. DONE!

I hope, your configuration now works fine.

7. Some notes

You can import your old postfix logfiles with command:

# /somewhere/scripts/perl/postfix/ < /var/log/mail/mail.log

Document written by Lubomir Host 'rajo' <rajo AT>
Fri, 16 Sep 2005 22:51:50 +0200

Platon Group <>
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok