Mail-in-a-Box Usage Report via Email

I know this could end up as a thread for potential improvements to the report, but may I just say that my hats off to the person that setup this report to be simple and an excellent overview for my new Miab instance! I’ve zz’d out specific users. Great job to those that have come before me! ~ your work matters!

My nice simple UX log below

Scanning logs from 2019-08-05 03:00:02 to 2019-08-12 03:00:02
17942 Log lines scanned, 8929 lines parsed in 0.50 seconds

Sent email
══════════ 

                                  sent hosts │ timespan
─────────────────────────────────────────────┼──────────────
zzz@zzzzzzz.com                      3     1 │ 19:07 - 19:17
zzzzz@zzzzzzz.com                    2     1 │ 2.3 days
zzzzzzzzzzzzz@zzzzzzz.com            1     1 │ 17:21
─────────────────────────────────────────────┼──────────────
Totals:                              6     3 │ 4.04 days
┬ totals by time of day:
│ hour  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 
│ sent  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  1  0  4  0  0  0  0 
└─────────────────────────────────────────────────────────────────────────────

Received email
══════════════ 

                                  received │ timespan
───────────────────────────────────────────┼─────────
zzz@zzzzzzz.com                         13 │ 1.0 days
zzzzz@zzzzzzz.com                       32 │ 5.7 days
───────────────────────────────────────────┼─────────
Totals:                                 45 │ 6.67 days
┬ totals by time of day:
│ hour      0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 
│ received  0  0  0  4  0  0  0  0  0  4  6  4  0  3  7  0  2  0  4  9  1  1  0  0 
└─────────────────────────────────────────────────────────────────────────────────

User logins per hour
════════════════════ 

                                  imap smtp mana │ timespan
─────────────────────────────────────────────────┼─────────
zzz@zzzzzzz.com                   12.1  0.1  0.1 │ 1.2 days
zzzzz@zzzzzzz.com                  4.3  0.0  0.0 │ 6.7 days
zzzzzzzzzzzzz@zzzzzzz.com            0    0    0 │ 17:21
─────────────────────────────────────────────────┼─────────
Totals:                           16.4  0.1  0.1 │ 6.67 days
┬ totals by time of day:
│ hour  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17  18  19  20  21 22 23 
│ imap  7  3  0  2  1  2  6  4  3  0  0 59 52 53  2  0  0  0 110 176 161 276 66 60 
│ smtp  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  1   0   4   0   0  0  0 
│ mana  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   4   0   0   0  0  0 
└─────────────────────────────────────────────────────────────────────────────────
1 Like

Sadly, I have not found the weekly report to be based on reality. :frowning:

I have installed pflogsumm on my MiaB instance. Much better reporting.

I am thinking of suggesting that it be installed by default on git-hub but don’t know if there would be enough demand for it or not.

Look at this thread for more info:

Interesting and yes, I’d love a deeper dive into something with more detail (I’d like to know more about pflogsumm) but also feel sometimes it’s the simplicity of a basic overview that confirms things are on or off track that strikes the right balance. Using Miab for a smaller domain (2 months now) and I’ve had a positive experience on many levels and just want to put some positivity out here to all those involved in addition to the ideas for improvement.

I also installed pflogsumm together with mailutils to send the report by email. I have added it to the /root/mailinabox/management/daily_tasks.sh script like:

/usr/sbin/pflogsumm /var/log/mail.log --smtpd-stats|mail -s “Mail-in-a-Box pflogsumm Report” postmaster@mydomain.tld

@Sjoerd Any other steps - I’d like to try this > can you recommend a how-to I could follow.

Does it send an email report also?

Also more on the security than operational front, I wonder if anyone is using something like logwatch https://linux.die.net/man/8/logwatch for notifications also that give us that feeling that everything is under control :wink:

Might I suggest that you change the command to:

/usr/sbin/pflogsumm -d yesterday /var/log/mail.log

This will give you a report for the one day rather than for whatever time period the entire log file covers.

@admecoach How detailed do you need? If you are somewhat familiar with the command line you just need to:

sudo apt install pflogsumm mailutils

Once installed read through the man page to get a feel for the report options that are available.

To run it and see the output on your screen:

sudo /usr/sbin/pflogsumm -d yesterday /var/log/mail.log | less

which pipes the output to less, so that you can read it all … other options would be to redirect the output to a file by:

sudo /usr/sbin/pflogsumm -d yesterday /var/log/mail.log > /home/user/filename

replace /home/user/filename with the path to the file you want to create.

And lastly if you want the output to be emailed then:

sudo /usr/sbin/pflogsumm -d yesterday /var/log/mail.log |mail -s "Desired subject for email" user@domain.tld

Note, that I left off the smtpd-stats as those stats are not really useful to me.

Personally, rather than changing the MiaB script, I added a cron job. I have webmin installed on my MiaB servers and added the cron job via webmin so I cannot really give any guidance on how to add a cron job via the command line.

Appreciate this help and the yesterday time period does seem best for monitoring without smtpd-stats too. Good info!

true, but on my mib, logrotates the mail.log file every week, so it doesn’t matter to me.

Then you’ll want to use /var/log/mail.log.1 to have the entire week’s log.

This topic was automatically closed after 61 days. New replies are no longer allowed.