in reply to Log Monitor

A user of exim myself, one nice thing is that all messages will carry a unique ID (the 16MqNV.. above), and this can be used to parse through the log once and then spit out stats.

The best way to do this , in this case is similar to the following, in which you split each line, look for the unique ID, and push the rest into a hash of arrays.

my %mailhash; while (<LOG>) { my( $date, $time, $message, @rest ) = split /\s+\; if ( $message ~= /^\w{6}\-\w{6}\-\w{2}$/ ) { $mailhash{ $message } ||= []; push @{ $mailhash{ $message } }, join(" ", @rest); } }
Note that you can also collect statistics at this point, but because it sounds like to want to do this while the log is active, you ought to read through the log as fast as possible, then proccess after that step. Doing the stats while reading may be problematic.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: Log Monitor
by particle (Vicar) on Jan 05, 2002 at 19:56 UTC
    you might want to throw the date and time back in there, as well

    push @{ $mailhash{ $message } }, join(" ", $date, $time, @rest);
    excellent point about separating the reading from the processing.

    ~Particle