Skip to main content

maillogger

PyPI PyPI - Python Version PyPI - License

Analysis tool for Postfix log in /var/log/maillog

Feature

  • Load maillog file
    • Identify text or gzip automatically
  • Parse maillog
    • Use regex
    • Convert to Python dictionary
  • Output the parsed maillog to files
    • Supported data format is CSV, TSV and JSON
    • Compression (gzip) is possible

Installation

pip install maillogger

Usage

usage: maillogger [-h] [-f {csv,tsv,json}] [-c] [-V] source_file target_file

Analysis tool for Postfix log in /var/log/maillog

positional arguments:
  source_file           Specify Postfix maillog file
  target_file           Specify the filename to write parsed maillog. The file
                        extension is automatically added to the end of
                        filename.

optional arguments:
  -h, --help            show this help message and exit
  -f {csv,tsv,json}, --format {csv,tsv,json}
                        File data format to write the parsed maillog (Default:
                        csv)
  -c, --compress        Compress the output file with gzip
  -V, --version         Show maillogger command version

Examples

Output a CSV file

maillogger /var/log/maillog result

or

maillogger /var/log/maillog result -f csv

Then, result.csv is generated in current working directory.

Output a JSON file

maillogger /var/log/maillog result -f json

Output a TSV file

maillogger /var/log/maillog result -f tsv

Output a compressed CSV file

maillogger /var/log/maillog result -f csv -c

Then, result.csv.gz is generated in current working directory.

Use Case

Analysis using MySQL

  1. Convert maillog text to CSV file
maillogger /var/log/maillog /path/to/any -f csv
  1. Create Table
CREATE TABLE maillog
(
    mail_id VARCHAR(15) NOT NULL,
    to_address VARCHAR(50) NOT NULL,
    relay text,
    delay VARCHAR(10),
    delays VARCHAR(20),
    dsn VARCHAR(10),
    status VARCHAR(10),
    description text,
    datetime DATETIME NOT NULL,
    PRIMARY KEY (mail_id, datetime),
    INDEX i_status(status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  1. Load CSV file
LOAD DATA INFILE '/path/to/any.csv'
IGNORE INTO TABLE maillog
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;

Metadata

Release files for maillogger 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maillogger 0.2.0
File Size Uploaded
maillogger-0.2.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for maillogger 0.2.0
File Interpreter ABI Platform
maillogger-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / maillogger-0.2.0.tar.gz

Download URL maillogger-0.2.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ed955cb9aac03b99b3e4f7bad6c3bc12339cdfb5abb54367599c1bcf4e5d3ccc
BLAKE2b-256 checksum
How to use checksums
cfa27783c35b676e2bb4cc6c20f2ab87698e7f52fe7dc244ca954e7f63b86122
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.5 Linux/5.3.0-1034-azure

Release files / maillogger-0.2.0-py3-none-any.whl

Download URL maillogger-0.2.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
117968bd7fa78364b037a23edb953df5fe8dec2a80833118f9b6b754d85ce0e2
BLAKE2b-256 checksum
How to use checksums
682bcc1775eec3db82c9c4646b086687e44c166ef86fb45474eda1c3d30c1ed5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.5 Linux/5.3.0-1034-azure

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page