Bug#476541: exim4-base: please handle nearly-empty logfile in daily cronjob stats
Justin Pryzby
justinpryzby at users.sourceforge.net
Mon Apr 21 13:39:53 UTC 2008
On Mon, Apr 21, 2008 at 08:43:22AM +0200, Marc Haber wrote:
> On Sun, Apr 20, 2008 at 09:30:33PM -0400, Justin Pryzby wrote:
> > I rewrote your patch to use a tempfile instead to reduce code
> > duplication.
>
> I'd rather have a few megs of code grepped twice than using a tempfile.
I don't know if I understand exactly what you mean (the code is not
grepped but rather the logfile data), but that's otherwise fair. I
tested the attached patch just now, with the following changes from
your initial copy:
. redirect stderr (twice);
. write non-statistic output to stdout (the cronjob pipe), rather
than sending a separate mail.
. Fix regex: don't escape "." within a bracket expression (it's
literal without escaping)
Justin
-------------- next part --------------
--- exim4-base 2008-04-21 09:21:40.000000000 -0400
+++ /etc/cron.daily/exim4-base 2008-04-21 09:35:53.000000000 -0400
@@ -11,6 +11,7 @@
# checking mechanisms or don't care.
E4BCD_DAILY_REPORT_TO=""
+E4BCD_DAILY_REPORT_OPTIONS=""
E4BCD_WATCH_PANICLOG="yes"
E4BCD_PANICLOG_NOISE=""
E4BCD_GNUTLS_PARAMS_MAXAGE="14"
@@ -34,10 +35,21 @@
# Patches for more sophisticated processing are appreciated via the
# Debian BTS.
+E4BCD_MAINLOG_NOISE="^[[:digit:][:space:]:-]\{20\}\(\(Start\|End\) queue run: pid=[[:digit:]]\+\|exim [[:digit:].]\+ daemon started: pid=[[:digit:]]\+, \+.*\)$"
+
if [ -n "$E4BCD_DAILY_REPORT_TO" ]; then
- if [ -x "$(command -v eximstats)" ]; then
- eximstats </var/log/exim4/mainlog \
- | mail $E4BCD_DAILY_REPORT_TO -s"$(hostname --fqdn) Daily email activity report"
+ if [ -x "$(command -v eximstats)" ] && [ -x "$(command -v mail)" ]; then
+ if [ "$(< /var/log/exim4/mainlog grep -v "$E4BCD_MAINLOG_NOISE" 2>/dev/null | wc -l)" -gt "0" ]; then
+ < /var/log/exim4/mainlog grep -v "$E4BCD_MAINLOG_NOISE" 2>/dev/null |
+ eximstats $E4BCD_DAILY_REPORT_OPTIONS |
+ mail $E4BCD_DAILY_REPORT_TO -s"$(hostname --fqdn) Daily e-mail activity report"
+ else
+ echo "no mail activity in this interval"
+ fi
+ else
+ echo "The exim4 cron job is configured to send a daily report, but eximstats"
+ echo "and/or mail cannot be found. Please check and make sure that these two"
+ echo "binaries are available"
fi
fi
More information about the Pkg-exim4-maintainers
mailing list