Skip to content

Adding daily mail review from Issue 839#881

Merged
johansmitsnl merged 23 commits intodocker-mailserver:masterfrom
akmet:issue-839
Mar 18, 2018
Merged

Adding daily mail review from Issue 839#881
johansmitsnl merged 23 commits intodocker-mailserver:masterfrom
akmet:issue-839

Conversation

@akmet
Copy link
Copy Markdown
Contributor

@akmet akmet commented Mar 7, 2018

I added the daily summery email as requested in #839.
I have not added any tests, because I never worked with this kind of tests and does not really know how to make them and what exact test for. Hope someone can help here?

Currently the script analyzes the /var/log/mail/mail.log and I think logrotate will cause a loss in information when it gets executed. One way to solve this problem could be running logrotate every day at midnight (what I am using in production system) and analyze the mail.log.1 which represents the day before.
Another way could be to analyze the combination of mail.log.1 and mail.log but this just doesn't feels right. Any thoughts?

Copy link
Copy Markdown
Contributor

@johansmitsnl johansmitsnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you resolve the conflict in the start script an look at these notes?

Comment thread target/bin/dailysummery Outdated
test -x /usr/sbin/pflogsumm || exit 0
test -x /usr/bin/bsd-mailx || exit 0

/usr/sbin/pflogsumm /var/log/mail/mail.log -d yesterday --problems-first | /usr/bin/bsd-mailx -s "Daily Summery for HOSTNAME" DAILY_SUMM_EMAIL
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the variable be: $DAILY_SUMM_EMAIL ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got problems with sed when used $. Removing it fixed the error..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if you encapsulate the variable with "?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used the following line and it does not replace the variable:
sed -i -r 's/$HOSTNAME/'$HOSTNAME'/g' /usr/local/bin/postfix-summary
and
sed -i -r 's/$HOSTNAME/'$HOSTNAME'/g' /usr/local/bin/postfix-summary

Comment thread target/start-mailserver.sh Outdated
function _setup_daily_summery() {
notify 'task' 'Setting up daily summery'

DAILY_SUMM_EMAIL=${DAILY_SUMM_EMAIL:="0"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default should be set at the start of the script.

Comment thread target/start-mailserver.sh Outdated
sed -i -r 's/HOSTNAME/'$HOSTNAME'/g' /usr/local/bin/dailysummery
sed -i -r 's/DAILY_SUMM_EMAIL/'$DAILY_SUMM_EMAIL'/g' /usr/local/bin/dailysummery

echo "/usr/local/bin/dailysummery" > /etc/cron.daily/dailysummery
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the daily directory should contain executable scripts?
Just to confirm.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

due to using logrotate this is obsolet

@Starbix
Copy link
Copy Markdown
Contributor

Starbix commented Mar 7, 2018

It'd be great if you could change summery to summary

@johansmitsnl
Copy link
Copy Markdown
Contributor

@17Halbe could you assist with the tests?

@17Halbe
Copy link
Copy Markdown
Contributor

17Halbe commented Mar 8, 2018

Hey, what a great idea!
I'll be busy the next few days, but I'll give it a try.
What about sendmail instead of bsd-mailx wasn't it working properly?
I don't know pflogsumm, but if we already introduce a new env variable, what about letting the user decide between daily/weekly/monthly(?) mails?
The tests would need to confirm, that a mail is being sent by cron, right? That shouldn't be a problem.

Comment thread Dockerfile Outdated
amavisd-new \
arj \
binutils \
bsd-mailx \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't sendmail working for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to do so. But maybe it was just my fault.
Could you provide an example on how to use sendmail? Is there something already existing here I could adapt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/tomav/docker-mailserver/blob/a73692cc9fb98849bb0eac72311f4966ecaaca41/test/tests.bats#L1368
I haven't tried using it, but the tests seem to work if one is using it like this..
I don't like the way sendmail works either. It's different on every system, sometimes a symlink to some other mail service and then there are about a couple different implementations, all with different syntaxes... 🙄

@akmet
Copy link
Copy Markdown
Contributor Author

akmet commented Mar 10, 2018

@17Halbe Just had a look at manpage
It can just analyze today, yesterday or the complete log file.
But we could do this with logrotation and after each rotation we just analyze the old log and send an email.
What do you think?

@17Halbe
Copy link
Copy Markdown
Contributor

17Halbe commented Mar 10, 2018

I think that would be overkill. ;) In that case, I think it‘s not worth the effort.
Unless you like to do it for fun and practice! :) (Isn‘t that the reason we are all doing this anyway?)

@akmet
Copy link
Copy Markdown
Contributor Author

akmet commented Mar 10, 2018

When using in production we have to edit logrotate anyway because if not we are skipping one day as I mentioned above..

@akmet
Copy link
Copy Markdown
Contributor Author

akmet commented Mar 12, 2018

Travis failed cause because the postfix-accounts.cf file keeps removing while the container runs.
I can reproduce this on my desktop (win10 with docker running on Windows and Ubuntu Bash) and I don't understand why. Can someone reproduce this?

@johansmitsnl
Copy link
Copy Markdown
Contributor

Is the file gone or is it empty?

@akmet
Copy link
Copy Markdown
Contributor Author

akmet commented Mar 13, 2018

Like both?
Windows Explorer shows the file, but I cannot open it ("File does not exist. Create File?") and I cannot write to it. The file only disappears when restarting the Docker Daemon.
I have no idea why this happens and I think that I then had to use my notebook for changes and git.

@johansmitsnl
Copy link
Copy Markdown
Contributor

I don't know why that is, maybe change de filesystem of docker?

Could you also add a test by calling the function and verify the email has been send and it contains the correct subject and to address?

@17Halbe
Copy link
Copy Markdown
Contributor

17Halbe commented Mar 15, 2018

I‘ll take care of the test. Probably today.

@akmet
Copy link
Copy Markdown
Contributor Author

akmet commented Mar 15, 2018

Me neither. But I installed Ubuntu next to Windows and started with a fresh master and now it seems to run.
I would also test if the interval is correctly set and if the logrotate config is set with defaults when no variable is set.

@johansmitsnl johansmitsnl merged commit a420b15 into docker-mailserver:master Mar 18, 2018
@johansmitsnl
Copy link
Copy Markdown
Contributor

Good work!

johansmitsnl added a commit that referenced this pull request Mar 19, 2018
Release 5.8.0

* Adding daily mail review from Issue 839 (#881)
  You can enable REPORT_RECIPIENT for REPORT_INTERVAL
  reports. Default is disabled.
* introducing ENABLE_SRS env variable (#906, #852)
  In v3.2.0 was SRS introduced and enabled by default
  Now it is disabled by default and can be enabled with
  the new env variable.
* fixed delalias, added additional tests (#909)
  Fixes to setup where made for deletion and addition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants