Current time: 11-25-2024, 07:38 PM Hello There, Guest! (LoginRegister)


Post Reply 
Mail traffic accounting
Author Message
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #17
RE: Mail traffic accounting
ispcomm Wrote:I missed something: When external mail arrives for a forwarded account do you count the size * 2 ? That is... 1MB arrives and 1MB leaves to the forwarded account. 2MB total for this email should be added to the domain.

This is the Test case 4 example. Final count is mail_size * 2 so it's ok with my last patch.

ispcomm Wrote:I'll try to propose a simpler solution for amavis-on case. It assumes that deliveries to amavis will be on consecutive lines (probably true 99% of the time):
This may work, I don't really know if this is true 99% of the time or just 80% or whatever though.

ispcomm Wrote:-) Count all deliveries to 127.0.0.1, but skip consecutive lines of the same value (i.e. the multiple recipients of the same mail).
Hmm... just piping the awk's output through "uniq" may work here Wink

ispcomm Wrote:-) Ignore all virtuals (they were accounted for on step 1).
Last patch version does just this (only if amavis is on, of course).

ispcomm Wrote:-) Count all other SMTP traffic, mapping every destination address to the domain that forwarded it.
Outgoing (forwarded) deliveries have no info about the original recipient, as in test case 4 (second smtp):
Code:
2008-06-19 08:17:35 me@external.dmn redir@dmn.tld test.server.tld 127.0.0.1 SMTP - 1 778303
2008-06-19 08:17:35 me@external.dmn me@external.dmn test.server.tld mx.external.dmn SMTP - 1 778674
There is no easy way of reverse-mapping "me@external.dmn" to "redir@dmn.tld" (it may seem easy here, but there could be some more deliveries between those lines). We would probably need to modify maillogconvert in order to do it...

ispcomm Wrote:Another issue: What happens when a delivery is deferred?
Deferred deliveries are filtered out by maillogconvert. As my current approach doesn't use any context info (no "same as last line" nor reverse-mappings or queue id tracking), the traffic will be properly accounted when the delivery is done correctly. The only problem in this regard is that incoming traffic may never be accounted if a mail sent to a forwarded address is undeliverable, but it's not a common case (why would someone redirect an account they own to one that doesn't work?).

Actually, my solution isn't that complicated. The relevant logic lies on those lines (virtual deliveries are stripped out before by awk, so both solutions would be the same in this regard):
Code:
+                if ((!exists $main::smtp_traffic{$smtp_from_domain}) && (!exists $main::smtp_traffic{$smtp_to_domain})) {
+                    next;
+                }
+                if (exists($forwarders_table{$smtp_to_mail})) {
+                    $extra_size = $traffic_size / $forwarders_table{$smtp_to_mail};
+                    $main::smtp_traffic{$smtp_to_domain} += $extra_size;
+                }
So 7 lines of logic that may be further reduced to 6 (I only use $external_size var to debug, it should be removed in a final version patch). Could you implement the reverse-mapping that easily? Wink
(This post was last modified: 06-20-2008 09:49 AM by kilburn.)
06-20-2008 09:34 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Mail traffic accounting - ispcomm - 06-13-2008, 11:09 PM
RE: Mail traffic accounting - ispcomm - 06-14-2008, 05:10 AM
RE: Mail traffic accounting - kilburn - 06-18-2008, 10:40 AM
RE: Mail traffic accounting - ispcomm - 06-18-2008, 05:33 PM
RE: Mail traffic accounting - kilburn - 06-18-2008, 09:22 PM
RE: Mail traffic accounting - ispcomm - 06-18-2008, 11:16 PM
RE: Mail traffic accounting - kilburn - 06-19-2008, 12:57 AM
RE: Mail traffic accounting - ispcomm - 06-19-2008, 03:30 AM
RE: Mail traffic accounting - ispcomm - 06-19-2008, 04:46 AM
RE: Mail traffic accounting - kilburn - 06-19-2008, 06:25 AM
RE: Mail traffic accounting - kilburn - 06-19-2008, 08:30 AM
RE: Mail traffic accounting - ispcomm - 06-19-2008, 05:18 PM
RE: Mail traffic accounting - Zothos - 06-19-2008, 08:20 PM
RE: Mail traffic accounting - kilburn - 06-20-2008, 02:04 AM
RE: Mail traffic accounting - kilburn - 06-20-2008, 03:51 AM
RE: Mail traffic accounting - ispcomm - 06-20-2008, 07:31 AM
RE: Mail traffic accounting - kilburn - 06-20-2008 09:34 AM
RE: Mail traffic accounting - ispcomm - 06-20-2008, 05:34 PM
RE: Mail traffic accounting - kilburn - 06-20-2008, 09:58 PM
RE: Mail traffic accounting - ispcomm - 06-20-2008, 11:54 PM

Forum Jump:


User(s) browsing this thread: 7 Guest(s)