procmail
[Top] [All Lists]

Re: counting message size from two different relays

2004-02-25 12:12:29
At 18:18 2004-02-25 +0100, Michael Meltzer wrote:
[big-ole-snip - the list is archived]

FTR, speaking in general terms instead of providing concrete examples of headers (particularly, the topmost Received: header, which is most applicable to your query) makes it that much more difficult to compose an accurate recipe for your specfic situation.

On my mailserver I get mail for two domains. The MX record for the first domain points to my mailserver. The MX record for the second domain points to a mail relay.

Which uhm, must relay it to you if you have a prayer of seeing it with procmail on this host, so that host should be in your regexp.

Your script works fine for the latter situation but not for the former one.

Translation: every message which _isn't_ from that specific relay. That could be done by breaking the hostname determination out to a separate recipe, and using an ELSE recipe after that to define a default hostname to show for regular message. Using my second recipe as a basis:

# you might rather anchor the second condition to the beginning of the
# variable, or prefix the match operator with a word delimiter regexp if you
# want to match multiple hosts at a given domain)
:0
* ^Received: from \/[^  ]*
* MATCH ?? ()\/(server\.tld|server2\.tld|local_host_name\.tld)
{
        RELAYHOST=$MATCH
}

# this executes only if the above did not
:0E
{
        RELAYHOST="outside mailer"
}

# Apparently, we're supposed to count the bytes on ALL messages.  Yuck.
:0
* 1^1 H ?? > 1
* 1^1 B ?? > 1
{
        PM_SCORE=$=
        IGNORE=`echo "  Folder: $RELAYHOST      $PM_SCORE" >> stats.log`
}


Grepping your mail log may prove to be a lot less process intensive in the long run, as the message sizes and relay hosts are simply recorded in the entries there, and I somehow doubt you really need realtime access to these stats.

On the mailserver there is also the internal traffic which I don't want to count or which should be summarized also separately.

Sounds like fun Those should have the local host entry for the topmost Received: header, so just add that to your regexp check (as I've done above).

BTW, you're aware of the sendmail program "mailstats" ?

Finally I want to summarize the size of mails comming from the mail relay and the size of mails coming from outside directly to my server each in a separate sum.

I think you get to deal with some of this job, or perhaps someone else here can do this part for you. I've got that miserable thing called "eeking out a living" to go contend with.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail