Skip to content

Using pflogsumm with Ubuntu 20.04

Jamen edited this page May 13, 2022 · 6 revisions

pflogsumm is a nice utility for getting concise hourly/daily mail statistics from postfix, It parses log files that are piped into it.

Unfortunately The mail.log files in Ubuntu 20.04 were a little different than they have been in the past. I had to make some permission modifications to allow pflogsumm to read them.

Permissions in Ubuntu 20.04 are set on log files at boot. Any permissions to log files in /var/log that are modified with chown will be overwritten at the next boot. To circumvent this:

Edit /usr/lib/tmpfiles.d/00rsyslog.conf

Set the permissions to something similar, a little less restrictive than the default.

z /var/log/mail.log 0644 syslog adm -

Now cat /var/log/mail.log | pflogsumm -d today | more should output correctly and can be called by non-root users and scripts.

It should be noted that if rsyslog is updated the entries in the 00rsyslog.conf file are reverted as well.

Here's another script to keep permissions nice and accessible.

#!/bin/bash

sed -i 's@z /var/log/mail.log 0640 syslog adm -@z /var/log/mail.log 0644 syslog adm -@g' /usr/lib/tmpfiles.d/00rsyslog.conf
chmod 644 /var/log/mail.log