Mail::MtPolicyd::Plugin::Accounting(3pm)

NAME
Mail::MtPolicyd::Plugin::Accounting - mtpolicyd plugin for accounting in sql tables

VERSION
version 2.05

SYNOPSIS
  <Plugin acct-clients>
    module = "Accounting"
    # per ip and user
    fields = "client_address,sasl_username"
    # statistics per month
    time_pattern = "%Y-%m"
    table_prefix = "acct_"
  </Plugin>

This will create a table acct_client_address and a table acct_sasl_username.

If a request is received containing the field the plugin will update the row in the fields table. The key is the fields value(ip or username) and the time string build from the time_pattern.

For each key the following counters are stored:

  * count
  * count_rcpt (count per recipient)
  * size
  * size_rcpt  (size * recipients)

The resulting tables will look like:

  mysql> select * from acct_client_address;
  +----+--------------+---------+-------+------------+--------+-----------+
  | id | key          | time    | count | count_rcpt | size   | size_rcpt |
  +----+--------------+---------+-------+------------+--------+-----------+
  |  1 | 192.168.0.1  | 2014-12 |    11 |         11 | 147081 |    147081 |
  |  2 | 192.168.1.1  | 2014-12 |     1 |          1 |  13371 |     13371 |
  | 12 | 192.168.2.1  | 2014-12 |    10 |        100 | 133710 |   1337100 |
  ...

  PARAMETERS
The module takes the following parameters:

(uc_)enabled (default: on)
    Enable/disable this check.

fields (required)
    A comma separated list of fields used for accounting.

    For each field a table will be created.

    For a list of available fields see postfix documentation:

    http://www.postfix.org/SMTPD_POLICY_README.html

time_pattern (default: "%Y-%m")
    A format string for building the time key used to store counters.

    Default is to build counters on a monthly base.

    For example use:

      * "%Y-%W" for weekly
      * "%Y-%m-%d" for daily

    See "man date" for format string sequences.

table_prefix (default: "acct_")
    A prefix to add to every table.

    The table name will be the prefix + field_name.

DESCRIPTION
This plugin can be used to do accounting based on request fields.

AUTHOR
Markus Benning <ich@markusbenning.de>

COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.

This is free software, licensed under:

  The GNU General Public License, Version 2, June 1991