eximstats-cron
eximstats-cron
is a cronjob that runs eximstats
on your machine.
eximstats
is installed with exim4-base
on Debian/Ubuntu, so ut probably
already exists on your system. Why not use it to generate mailstatistics? :)
eximstats-cron
will use eximstats
to generate daily, weekly, monthly and
yearly statistics in HTML form which you can easily serve using some webserver.
Logging in exim4
For this script to work, you need to generate daily exim-logs. The following
option will make Exim output logs to /var/log/exim4/mainlog-YYYYMMDD
.
log_file_path = syslog : /var/log/exim4/%slog-%D
It needs to go into your exim4-config.
Since I like to find my latest logfiles in a location that doesn’t change every day, I have the following two lines in cron to make sure there is always a symlink pointing to the latest logfile. ```
This just symlinks latest logfiles
The backslashes before % in date
escapes %, because they’re a special cron-character.
00 00 * * * Debian-exim rm -f /var/log/exim4/mainlog-latest && ln -s /var/log/exim4/mainlog-$(date +\%Y\%m\%d) /var/log/exim4/mainlog-latest && touch /var/log/exim4/mainlog-$(date +\%Y\%m\%d) && chmod 640 /var/log/exim4/mainlog-$(date +\%Y\%m\%d) 00 00 * * * Debian-exim rm -f /var/log/exim4/rejectlog-latest && ln -s /var/log/exim4/rejectlog-$(date +\%Y\%m\%d) /var/log/exim4/rejectlog-latest && touch /var/log/exim4/rejectlog-$(date +\%Y\%m\%d) && chmod 640 /var/log/exim4/rejectlog-$(date +\%Y\%m\%d) ```
Setting up eximstats-cron
Just clone this repo somewhere, and symlink eximstats-cron
into
/etc/cron.daily/
. Easy-peasy. The logs will start to appear in
/var/log/eximstats
the very next day!