Postgrep

From Rixort Wiki
Jump to navigation Jump to search

Script for searching through Postfix log files, effectively like exigrep but for Postfix instead of Exim.

Language choice

Use Python for speed of development and cross-platform code.

Features

  • Specify multiple input files, will all be read and processed.
  • Automatically decompress .gz files in memory before reading.
  • Read all data into an SQLite 'in memory' file, which allows fast and detailed filtering.

Questions

  • How do we determine the year for each log entry? Could use current year, but what happens if we import logs from December and January?
  • How do we identify Postfix log entries?
  • Is it more efficient to process files line by line as we read them or slurp the file into a single variable and then iterate over that?