Mailing List Archive

Logging to a pipe
Hi all

I've just been mulling something over (in my head, mainly) while looking
at processing statistics from one of the machines under my control.

It struck me that if Exim was able to log to a pipe - i.e. send the
output it normally puts in the various other logs out to a child process
via a pipe - that we'd greatly extend the functionality and availability
of real-time stats packages which can monitor Exim and spit out graphs,
reports, alerts and so on.

I've had a brief scan of Bugzilla and can't see this mentioned there,
nor could I find mention of it in the -dev archive (and only one request
in the -users archive) so chewed on it a bit more. And then it hit me:

The way Exim spins off and reaps child processes - for deliveries and so
on - means that they themselves write to the various logfiles. In order
to write to a pipe, all the child processes need to know where/what that
pipe is. In the case of, for example, a manually- fired queue run, that
information pretty much won't exist and the child would therefore need
to run up the pipe itself.

Very quickly, on a busy server, we're talking about a massive overhead
(especially where Perl or other interpreted languages are used) -
spinning up, piping to, and reaping a child process for every
sub-process Exim generates. This is clearly a non-trivial load.

Am I missing the point, or have I fundamentally understood an issue
which would make logging to a pipe all but impossible?

As an adjunct to this... if the main/panic/reject logs were made FIFOs
instead, would that gain us anything (and I suspect the answer is "only
if you can guarantee something is on the other side of them").

Graeme


--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
Re: Logging to a pipe [ In reply to ]
On Wed, 1 Aug 2007, Graeme Fowler wrote:

> It struck me that if Exim was able to log to a pipe - i.e. send the
> output it normally puts in the various other logs out to a child process
> via a pipe - that we'd greatly extend the functionality and availability
> of real-time stats packages which can monitor Exim and spit out graphs,
> reports, alerts and so on.

But you can already "tail" the main log file to achieve this in as near
real-time as you like. That's how eximon works.

> The way Exim spins off and reaps child processes - for deliveries and so
> on - means that they themselves write to the various logfiles.

Exactly ... and rely on the operating system to keep it all under
control and not intermingle the data from the different writes by the
different processes. The OS does this just fine. With any other
hand-driven technique, complicated locking would no doubt be needed.

> As an adjunct to this... if the main/panic/reject logs were made FIFOs
> instead, would that gain us anything (and I suspect the answer is "only
> if you can guarantee something is on the other side of them").

Indeed, and I'm not sure if the same kind of interlocking would occur -
it might, I just don't know.

--
Philip Hazel University of Cambridge Computing Service
Get the Exim 4 book: http://www.uit.co.uk/exim-book

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
Re: Logging to a pipe [ In reply to ]
On Thu, 2007-08-02 at 09:00 +0100, Philip Hazel wrote:

> > It struck me that if Exim was able to log to a pipe - i.e. send the
> > output it normally puts in the various other logs out to a child process
> > via a pipe - that we'd greatly extend the functionality and availability
> > of real-time stats packages which can monitor Exim and spit out graphs,
> > reports, alerts and so on.
>
> But you can already "tail" the main log file to achieve this in as near
> real-time as you like. That's how eximon works.

And even better, if you use 'inotail' on Linux then you get a
notification from the kernel every time the other process writes and you
can then read from the file.

johannes
Re: Logging to a pipe [ In reply to ]
Johannes Berg wrote:
> On Thu, 2007-08-02 at 09:00 +0100, Philip Hazel wrote:
>
>>> It struck me that if Exim was able to log to a pipe - i.e. send the
>>> output it normally puts in the various other logs out to a child process
>>> via a pipe - that we'd greatly extend the functionality and availability
>>> of real-time stats packages which can monitor Exim and spit out graphs,
>>> reports, alerts and so on.
>> But you can already "tail" the main log file to achieve this in as near
>> real-time as you like. That's how eximon works.
>
> And even better, if you use 'inotail' on Linux then you get a
> notification from the kernel every time the other process writes and you
> can then read from the file.
>
> johannes
>

Or use the syslogd pipes

--
The Exim Manual
http://www.exim.org/docs.html
http://www.exim.org/exim-html-current/doc/html/spec_html/index.html

--
## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##