[Kolab-devel] Postfix statistics

gelpi@corona.it corona at gelpi.it
Fri Jan 12 09:18:03 CET 2007


Hi,
    /kolab/etc/rc.d/rc.postfix every day generates the log summary 
statistics writing file /kolab/var/postfix/log/postfix.sum

Due to kolab configuration every mail is counted three times in postfix.sum.

Infact every mail is injected other two times in postfix,  one after 
amavis and another after kolabfilter.

I modified pflogsumm to avoid counting the same message three time.

Perhaps there are other way to do it.

Here is the diff file

** /kolab/sbin/pflogsumm.ori   2006-01-03 19:26:46.000000000 +0100
--- /kolab/sbin/pflogsumm       2006-01-28 18:07:11.000000000 +0100
***************
*** 426,432 ****
      %rcvdMsg, $msgsFwdd, $msgsBncd,
      $msgsDfrdCnt, $msgsDfrd, %msgDfrdFlgs,
      %connTime, %smtpdPerDay, %smtpdPerDom, $smtpdConnCnt, $smtpdTotTime,
!     %smtpMsgs
  );
  $dayCnt = $smtpdConnCnt = $smtpdTotTime = 0;

--- 426,433 ----
      %rcvdMsg, $msgsFwdd, $msgsBncd,
      $msgsDfrdCnt, $msgsDfrd, %msgDfrdFlgs,
      %connTime, %smtpdPerDay, %smtpdPerDom, $smtpdConnCnt, $smtpdTotTime,
!     %smtpMsgs,
!     %exCluded,%msgsID
  );
  $dayCnt = $smtpdConnCnt = $smtpdTotTime = 0;

***************
*** 591,603 ****
        ++$masterMsgs{(split(/^.*master.*: /, $logRmdr))[1]};
      } elsif($cmd eq 'smtpd') {
        if($logRmdr =~ /\[\d+\]: \w+: client=(.+?)(,|$)/o) {
!           #
!           # Warning: this code in two places!
!           #
!           ++$rcvPerHr[$msgHr];
!           ++${$msgsPerDay{$revMsgDateStr}}[0];
!           ++$msgsRcvd;
!           $rcvdMsg{$qid} = gimme_domain($1);  # Whence it came
        } elsif(my($rejSubTyp) = $logRmdr =~ /\[\d+\]: \w+: 
(reject(?:_warning)?|hold|discard): /o) {
            if($rejSubTyp eq 'reject') {
                proc_smtpd_reject($logRmdr, \%rejects, \$msgsRjctd,
--- 592,609 ----
        ++$masterMsgs{(split(/^.*master.*: /, $logRmdr))[1]};
      } elsif($cmd eq 'smtpd') {
        if($logRmdr =~ /\[\d+\]: \w+: client=(.+?)(,|$)/o) {
!           if($logRmdr =~ /\[\d+\]: \w+: client=localhost.localdomain/o) {
!               $logRmdr =~ /\[\d+\]: (\w+): client=(.+?)(,|$)/o;
!               @{exCluded{$1}} = (1);
!           } else {
!               #
!               # Warning: this code in three places!
!               #
!               ++$rcvPerHr[$msgHr];
!               ++${$msgsPerDay{$revMsgDateStr}}[0];
!               ++$msgsRcvd;
!               $rcvdMsg{$qid} = gimme_domain($1);      # Whence it came
!           }
        } elsif(my($rejSubTyp) = $logRmdr =~ /\[\d+\]: \w+: 
(reject(?:_warning)?|hold|discard): /o) {
            if($rejSubTyp eq 'reject') {
                proc_smtpd_reject($logRmdr, \%rejects, \$msgsRjctd,
***************
*** 663,668 ****
--- 669,677 ----
        my $toRmdr;
        if((($addr, $size) = $logRmdr =~ /from=<([^>]*)>, size=(\d+)/o) 
== 2)
        {
+           $logRmdr =~ /\[\d+\]: (\w+): /o;
+           next if(exists($exCluded{$1}));
+
            next if($msgSizes{$qid});   # avoid double-counting!
            if($addr) {
                if($opts{'m'} && $addr =~ 
/^(.*!)*([^!]+)!([^!@]+)@([^\.]+)$/o) {
***************
*** 707,712 ****
--- 716,725 ----
            (my $domAddr = $addr) =~ s/^[^@]+\@//o;     # get domain only
            if($status eq 'sent') {

+               # Was already counted
+               $logRmdr =~ /\[\d+\]: (\w+): /o;
+               next if(exists($exCluded{$1}));
+
                # was it actually forwarded, rather than delivered?
                if($toRmdr =~ /forwarded as /o) {
                    ++$msgsFwdd;
***************
*** 772,778 ****
        }
        elsif($cmd eq 'pickup' && $logRmdr =~ /: (sender|uid)=/o) {
            #
!           # Warning: this code in two places!
            #
            ++$rcvPerHr[$msgHr];
            ++${$msgsPerDay{$revMsgDateStr}}[0];
--- 785,791 ----
        }
        elsif($cmd eq 'pickup' && $logRmdr =~ /: (sender|uid)=/o) {
            #
!           # Warning: this code in three places!
            #
            ++$rcvPerHr[$msgHr];
            ++${$msgsPerDay{$revMsgDateStr}}[0];
***************
*** 791,796 ****
--- 804,830 ----
        }
        else
        {
+           if($logRmdr =~ /.* (\w+): message-id=<(.+)>/o) {
+              if(! exists($msgsID{$2})) {
+                 $msgsID{$2} = 0;
+                 if(exists($exCluded{$1})) {                           
# message comes from inside
+                    delete($exCluded{$1});                             
# it must be count
+                    #
+                    # Warning: this code in three places!
+                    #
+                    ++$rcvPerHr[$msgHr];
+                      ++${$msgsPerDay{$revMsgDateStr}}[0];
+                      ++$msgsRcvd;
+                      $rcvdMsg{$qid} = 
"localhost.localdomain";                # Whence it came
+                 }
+              } else {
+                ++$msgsID{$2};
+              }
+           }
+           if($logRmdr =~ /\[\d+\]: (\w+): removed/o) {
+              delete($exCluded{$1});                                   
# limit hash size
+           }
+
  #         print UNPROCD "$_\n";
        }
      }



-- 
Gelpi ing. Andrea
--------------------------------------------------------------
It took the computing power of three C-64s to fly to the Moon.
It takes a 486 to run Windows 95. Something is wrong here.
--------------------------------------------------------------




More information about the devel mailing list