SQL logging

Julian Field mailscanner at ecs.soton.ac.uk
Sun Feb 23 14:33:13 GMT 2003


I have written you some code which will do this:

1. Log information about every message to a temporary file while
MailScanner is running, giving you minimum performance hit. I've written
all the code you need to do this bit.
2. When MailScanner worker processes die of old age, or are shutdown
cleanly (don't use kill -9 on them!), they will read their log file and
pump the contents into an SQL database all at 1 go, which should be nice
and quick. There are bits missing from this, see the comments in the code.

I don't log everything about each message, but I log a fair chunk of info
about each one. I assume you will customise this to log what you reckon you
It creates 1 record per message (whether clean or infected) and then also
generates an extra record for each infection report. So a clean message
will produce 1 record, a message with 2 infections will produce 3 records.
The SQL "INSERT" code is deliberately missing. You can write that better
than me anyway.

To use it, apply the other patches I supplied the other day to give you a
new configuration option "Always Looked Up Last".
Then insert the attached file on the end of CustomConfig.pm and write the
SQL code you need, and create the database and the db table this lot is
going to be written to.
Then set
        Always Looked Up Last = &SQLLogging
in your MailScanner.conf and "restart" (not just "reload") MailScanner.

To find obvious syntax errors, I would advise you do
        perl -c CustomConfig.pm
before trying to use it, as that will catch syntax screw-ups.

I make no guarantees whatsoever about the attached code actually working. I
have written it to get you started, and to show you how to pull interesting
things out of the "Message" data structure. If you want the full list of
Message attributes, read the top of Message.pm.

Please let me know how you get on. If someone can post me some working code
with all the SQL bits written and tested, I will happily include it in
future releases (next release due on 1st March).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SQLLogging
Type: application/octet-stream
Size: 4416 bytes
Desc: not available
Url : http://lists.mailscanner.info/pipermail/mailscanner/attachments/20030223/e4861a95/SQLLogging.obj
-------------- next part --------------
Julian Field
MailScanner thanks transtec Computers for their support

More information about the MailScanner mailing list