Peter Hodur:
> On Tuesday, January 27, 2015, Wietse Venema <[email protected]> wrote:
> >
> >
> > This is typically done with "enable_long_queue_ids = yes", a program
> > that watches the maillog file, and a collection of regular expressions
> > that extract information.
> >
> >
> Thank you for tour reply. I know this option and i use it. But i do not
> want to parse log file. This will introduce some delay in processing and
> decision based on logged data. (For example, i want to monitor 5xx response
How much delay can you tolerate?
> ratio on individual sasl user names and block users in realtime - many 5xx
> errors is obviously indicator, that user send spam messages, so i can route
> it to another smtp client process with dedicate ip and/or block it)
>
> Instead i want to hook some function in postfix (may be function which
> flushes records to log file?) and add couple of lines of code that connect
> to redis database and puts there some statistics.
This still requires a collection of regexps to extract information,
so all you gain is a few milliseconds. Is that worth it?
> So i ask here, if someone with knowledge of postfix internals can tell me,
> what is the right place to add this code. What "function" to hook... I have
> read som source code of postfix and im not sure im able to identify right
> place to add my logging code)
You can register a logging function with msg_output().
Wietse
MSG_OUTPUT(3) MSG_OUTPUT(3)
NAME
msg_output - diagnostics output management
SYNOPSIS
#include <msg_output.h>
typedef void (*MSG_OUTPUT_FN)(int level, char *text)
void msg_output(output_fn)
MSG_OUTPUT_FN output_fn;
...
DESCRIPTION
This module implements low-level output management for the msg(3) diag-
nostics interface.
msg_output() registers an output handler for the diagnostics interface.
An application can register multiple output handlers. Output handlers
are called in the specified order. An output handler takes as argu-
ments a severity level (MSG_INFO, MSG_WARN, MSG_ERROR, MSG_FATAL,
MSG_PANIC, monotonically increasing integer values ranging from 0 to
MSG_LAST) and pre-formatted, sanitized, text in the form of a null-ter-
minated string.
Wietse