_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.3.1'
+__version__ = '0.3.2'
# =============================================================================
"""Initialize the PostfixLogfileParser object."""
self.chain = {}
self.active_smtpd_pid = {}
+ self.connect = {}
super(PostfixLogfileParser, self).__init__(
appname=appname, verbose=verbose, version=version, base_dir=base_dir,
self.chain = {}
self.active_smtpd_pid = {}
+ self.connect = {}
# -------------------------------------------------------------------------
def parse(self, fh):
"""Parse the content of a given logfile and store the results in self.chain."""
LOG.debug(_('Start parsing postfix logfile ...'))
- for line in fh.readlines():
- self.evaluate_logline(line)
+ try:
+ for line in fh.readlines():
+ self.evaluate_logline(line)
+ finally:
+ self.active_smtpd_pid = {}
# -------------------------------------------------------------------------
def evaluate_logline(self, line):
m_conn = self.re_connect.search(message)
if m_conn:
+ who = m_conn['client']
+ if who.lower() == 'unknown':
+ who = m_conn['addr']
+
chain = PostfixLogchainInfo(
client_host=m_conn['client'],
client_addr=m_conn['addr'],
)
self.active_smtpd_pid[pid] = chain
+ if who not in self.connect:
+ self.connect[who] = 0
+ self.connect[who] += 1
+
if self.verbose > 3:
msg = 'Creating Postfix log chain:\n' + pp(chain.as_dict())
LOG.debug(msg)