mentat.module.reporter module

This Mentat module is a script providing periodical event reports to target abuse groups.

This script is implemented using the pyzenkit.zenscript framework and so it provides all of its core features. See the documentation for more in-depth details.

It is further based on mentat.script.fetcher module, which provides database fetching and message post-processing capabilities.

Usage examples

# Display help message and exit. --help

# Run in debug mode (enable output of debugging information to terminal). --debug

# Run with insanely increased logging level. --log-level debug

# Run in TEST DATA mode and MAIL TEST mode, force all reports to go to
# ''. In test data mode only events tagged with 'Test'
# category will be processed (useful for debugging). In mail test mode
# all generated reports will be redirected to configured admin email (root
# by default) instead of original contact, which is again useful for
# debugging or testing. --mail-test-mode --test-data --mail-to

# Force reporter to use different email report template and localization. --template-id another --locale cs

Available script commands

report (default)

Generate report containing overall Mentat system performance statistics within configured time interval thresholds.

Brief overview of reporting algorithm

Reporting algorithm follows these steps:

  1. For all abuse groups found in database:

    1. For all event severities (low, medium, high, critical):

      1. Fetch reporting configuration settings.

      2. Fetch events with given severity, that appeared in database in given time window and belonging to that particular group.

      3. Filter events with configured reporting filters.

      4. Threshold already reported events.

      5. Fetch relapsed events.

      6. Generate summary and/or extra reports and store them to database.

      7. Send reports via email to target abuse contacts.

class mentat.module.reporter.MentatReporterScript[source]

Bases: mentat.script.fetcher.FetcherScript

Implementation of Mentat module (script) providing periodical statistical overview for message processing performance analysis.

CONFIG_EVENT_CLASSES_DIR = 'event_classes_dir'
CONFIG_FORCE_LOCALE = 'force_locale'
CONFIG_FORCE_MODE = 'force_mode'
CONFIG_FORCE_TEMPLATE = 'force_template'
CONFIG_FORCE_TIMEZONE = 'force_timezone'
CONFIG_REPORTS_DIR = 'reports_dir'
CONFIG_TEMPLATES_DIR = 'templates_dir'
CONFIG_TEMPLATE_VARS = 'template_vars'
CONFIG_TEST_DATA = 'test_data'
CORECFG_REPORTER = '__core__reporter'

Implementation of the report command (default).

Calculate statistics for messages stored into database within configured time interval thresholds.


Return the name of the default script command. This command will be executed in case it is not explicitly selected either by command line option, or by configuration file directive.


Name of the default command.

Return type


class mentat.module.reporter.SimpleFlock(path, timeout=None)[source]

Bases: object

Provides the simplest possible interface to flock-based file locking. Intended for use with the with syntax. It will create/truncate/delete the lock file as necessary.