Aleksandar Lazic wrote:
Dear List,

I use the qpsmtpd with the qpsmtpd-forkserver and syslog server logging.

logging/syslog loglevel LOGDEBUG

I must create some reports and the tools on
http://www.hjp.at/projekte/qpsmtpd/log-tools/

are not able to analyze this log, so I have tried to create a own
analyser based on the pid.

The problem is that the logentries are not uniq.

Same pid for more then one Mail.
Time in second is not uniq enough.

We create a sessionid by combining an invocation of temp_file() and config('me') (because we have multiple servers) and assign it to a transaction note during hook_mail.

I don't like parsing multiple ad-hoc log records to reconstruct a "proper" record describing an email. So, we use a hacked version of log_terse to include the sessionid in its "one record includes _everything_ about the email" record.

You can still use the transaction note for normal $self->log() invocations if you want.

This is the code we use in hook_mail to generate sessionid:

    my $sessionid = $self->qp->temp_file();
    $sessionid =~ s/^.*\///;    # lop off path prefix
    my @part = split(/:/, $sessionid);
    my $me = $self->qp->config("me");
    $me =~ s/\..*//;            # convert to node name.
    $sessionid = sprintf("%d.%05d%0...@%s", @part, $me);

    $transaction->notes('sessionid', $sessionid);

We don't use the ":" separators and need the odd sprintf for historical reasons - compability with a previous system's log analysis, which likes a UNIX time_t as a prefix terminated with ".". If you don't mind the colons, you can do without the split and sprintf. Eg:


    my $sessionid = $self->qp->temp_file();
    $sessionid =~ s/^.*\///;    # lop off path prefix
    $transaction->notes('sessionid',
        $sessionid . '@' . $self->qp->config("me"));

Reply via email to