On 2007-09-04 07:59:15 -0700, JT Moree wrote:
> > $instance_id        # could be opaque or structured to include server name
> >                 # or IP, PID, etc.
> > $instance_id.$connection_id         # identifies a connection handled
> >                             # by this instance
> > $instance_id.$connection_id.$transaction_id # identifies a
> >                                             # transaction within 
> >                                             # this connection.
> 
> I notice that svn code has moved to this model but it still has these
> lines in it
> 
>   my $SALT_HOST = crypt(hostname, chr(65+rand(57)).chr(65+rand(57)));
>   $SALT_HOST =~ tr/A-Za-z0-9//cd;
> 
> Is this being used anymore?  I don't find a reference to $SALT_HOST in
> the same file.

I was playing around a bit on the weekend, yes. Since neither Matt nor
Ask have cried out in horror on what I did, I guess it's time to present
that to a wider audience:

The instance id basically identifies Qpsmtpd::SMTP object. Looking
through the sources of various servers I found that there is always
exactly one per process (although with forkserver it is inherited by the
child processes), so I thought that 

    time when object was created (seconds.microseconds since the epoch)
    "host_id" 
    process id 

should always be unique. I replaced $SALT_HOST as the "host_id" with the
primary IP address (in hex), because I think a predictable host id is
useful (so that you can find the relevant host from the log entry -
otherwise the host id could be removed). It may be useful to replace the
IP address with something else, most likely the (abbreviated) hostname.
That could be a configuration option. (So this answers your question:
$SALT_HOST is obsolete and I just forgot to delete it)

The connection id and transaction id are simple counters. 

So a complete log entry (without timestamp or whatever else the logging
mechanism may add) looks like this:

1188729346.156197.7f000101.3165.2.1 Accepted connection 0/15 from 127.0.1.1 / 
Unknown

So this is instance "1188729346.156197.7f000101.3165" (started at
1188729346.156197 on host 127.0.1.1 (oops - the joys of dhcp and strange
/etc/hosts files) in process 3165). This is connection number 2 (i.e.
the first "real" connection (connection number 1 is used up during
startup) on this instance, and the first transaction within this
connection (since a "mail from" command always starts a new transaction,
you can think of transaction 2 as the first "real" transaction).

Apart from the fact that the "host id" thingy should probably be
configurable, there are some other things I'm not completely happy with:

* The id is rather long. That is written into every log line and the
  first 33 characters are always the same until you restart the
  instance. If you have only a handful of instances (which is quite
  likely) that's 33 characters for a few bits of information (at least
  it will compress well with gzip). We could use base64 instead of base
  10/16. Then the timestamp reduces to 6+4 (or 6+3 if we are content
  with 4 µs resolution) characters, the IP address to 6 characters and
  the PID to 3 characters. Now that's 20 characters including the
  dot, but it's quite opaque.

* The same delimiter is used within the instance id and between the
  instance id and the connection and transaction ids. This may make life
  unnecessarily hard for log analysis tools.

        hp


-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | [EMAIL PROTECTED]         |
__/   | http://www.hjp.at/ |    -- Sam in "Freefall"

Attachment: signature.asc
Description: Digital signature

Reply via email to