From a4a24cd6bb1527d2d7a841475d04dc313a5aea77 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 15 Apr 2024 10:29:03 +0200 Subject: [PATCH] Evaluating also stats per address in bin/get-intern-used-from-addresses --- lib/pp_admintools/app/get_from_addr.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/pp_admintools/app/get_from_addr.py b/lib/pp_admintools/app/get_from_addr.py index 628ce2f..e47bb79 100644 --- a/lib/pp_admintools/app/get_from_addr.py +++ b/lib/pp_admintools/app/get_from_addr.py @@ -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)) # ============================================================================= -- 2.39.5