]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Evaluating also stats per address in bin/get-intern-used-from-addresses
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 15 Apr 2024 08:29:03 +0000 (10:29 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 15 Apr 2024 08:29:03 +0000 (10:29 +0200)
lib/pp_admintools/app/get_from_addr.py

index 628ce2fa242e5599c3b491798333fb4c051de86a..e47bb793c59bf33b5f02574d07ad6ead6f415760 100644 (file)
@@ -23,7 +23,7 @@ from . import BaseDPXApplication
 from ..handler.pflogparse import PostfixLogfileParser
 from ..xlate import XLATOR
 
-__version__ = '0.5.1'
+__version__ = '0.6.0'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -73,6 +73,7 @@ class GetFromAddressesApp(BaseDPXApplication):
         self.logfiles = []
 
         self.per_domain = {}
+        self.per_address = {}
 
         self.show_address_results = False
 
@@ -211,6 +212,7 @@ class GetFromAddressesApp(BaseDPXApplication):
             if not chain.from_address:
                 continue
 
+            address = str(chain.from_address)
             domain = ''
             if isinstance(chain.from_address, MailAddress):
                 domain = chain.from_address.domain
@@ -238,12 +240,16 @@ class GetFromAddressesApp(BaseDPXApplication):
 
             if loghost not in self.per_domain:
                 self.per_domain[loghost] = {}
-
             if domain not in self.per_domain[loghost]:
                 self.per_domain[loghost][domain] = 0
-
             self.per_domain[loghost][domain] += 1
 
+            if loghost not in self.per_address:
+                self.per_address[loghost] = {}
+            if address not in self.per_address[loghost]:
+                self.per_address[loghost][address] = 0
+            self.per_address[loghost][address] += 1
+
     # -------------------------------------------------------------------------
     def _is_local_client(self, chain):
 
@@ -312,7 +318,10 @@ class GetFromAddressesApp(BaseDPXApplication):
 
         self._collect_results()
         if self.verbose > 0:
+            self.empty_line()
             LOG.debug(_('Results per domain:') + '\n' + pp(self.per_domain))
+            self.empty_line()
+            LOG.debug(_('Results per address:') + '\n' + pp(self.per_address))
 
 
 # =============================================================================