]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Feature] Add mapstats utility for multimap statistics analysis
authorAlexander Moisseev <moiseev@mezonplus.ru>
Mon, 2 Feb 2026 07:57:00 +0000 (10:57 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Mon, 2 Feb 2026 07:57:00 +0000 (10:57 +0300)
commit048d3a04b7a26c42bcffadced664a78f286680d3
tree7138d3172fb5aa546765214169cae651735d50df
parent8ebb25224c8551d0d4e470425ece79c8bd7fcd65
[Feature] Add mapstats utility for multimap statistics analysis

Introduce a new utility to analyze Rspamd logs and count matches for
multimap module patterns. This helps identify ineffective map entries
and optimize multimap configurations.

Features:
- Parse file-based multimap configurations from rspamadm configdump
- Load and validate map files with support for:
  * IP/CIDR patterns (IPv4/IPv6)
  * Regular expressions with PCRE flags (imsxurOL)
  * Plain string patterns (domains, hostnames, etc.)
  * Full-line and inline comments
- Process Rspamd logs (plain or compressed: bz2, gz, xz, zst)
- Match log entries against map patterns
- Generate statistics report grouped by map source files
- Show match counts and comments for each pattern
- Report unmatched symbol values for debugging

Installation:
- Added to CMake install rules (installs as 'mapstats')
- Added to RPM spec file
- Debian packaging works automatically via CMake

Usage:
mapstats -l /var/log/rspamd/rspamd.log
mapstats -l /var/log/rspamd -n 5        # Last 5 rotated logs
mapstats -l /var/log/rspamd --start 2024-01-01 --end 2024-01-31

Requirements:
- Perl 5.14+
- JSON::PP (core module)
- NetAddr::IP (optional, for type=ip maps only)
cmake/InstallRspamdFiles.cmake
rpm/rspamd.spec
utils/mapstats.pl [new file with mode: 0644]