Hi,

  Attached is a patch to exim4-base.cron.daily that implements what
has been described as an acceptable solution in this bug report:

  - If $E4BCD_WATCH_PANICLOG is set to "no", no reporting is done (no
change).
  - If it is set to "yes", non-zero size paniclog is always reported
(no change again).
  - If it is set to "once" however, a non-zero paniclog is reported
only if it has changed since the last time the cron.daily script has
run; so effectively only once for each time it changes.

  To implement this the script creates a zero size file in
/var/lib/exim4 called paniclog.timestamp, which would also mean that
the exim4-base package should contain /var/lib/exim4 (but this is just
nitpicking).

  Anyway, this first iteration is mostly meant to be a proof of
concept implementation. Of course if you like it you can add it as it
is, but I'm open to suggestions on how to make it better etc.

Thanks,
Vasilis

-- 
Vasilis Vasaitis
"A man is well or woe as he thinks himself so."


--- exim4-base.cron.daily.orig	2007-11-21 15:29:05.000000000 +0000
+++ exim4-base.cron.daily	2007-11-26 11:48:18.000000000 +0000
@@ -54,17 +54,22 @@
   fi
 }
 
-if [ "$E4BCD_WATCH_PANICLOG" = "yes" ]; then
+if [ "$E4BCD_WATCH_PANICLOG" != "no" ]; then
   if [ -s "/var/log/exim4/paniclog" ]; then
-    if [ -x "/usr/local/lib/exim4/nonzero_paniclog_hook" ]; then
-      /usr/local/lib/exim4/nonzero_paniclog_hook
-    fi
-    if [ -z "$E4BCD_PANICLOG_NOISE" ] || grep -vq "$E4BCD_PANICLOG_NOISE" /var/log/exim4/paniclog; then
-      log_this "ALERT: exim paniclog /var/log/exim4/paniclog has non-zero size, mail system possibly broken"
-      if ! printf "Subject: exim paniclog on %s has non-zero size\nTo: root\n\nexim paniclog /var/log/exim4/paniclog on %s has non-zero size, mail system might be broken" "$(hostname --fqdn)" "$(hostname --fqdn)" | exim4 root; then
-        log_this "PANIC: sending out e-mail warning has failed, exim has non-zero return code"
+    if [ "$E4BCD_WATCH_PANICLOG" != "once" ] || \
+       [ ! -e "/var/lib/exim4/paniclog.timestamp" ] || \
+       [ "/var/log/exim4/paniclog" -nt "/var/lib/exim4/paniclog.timestamp" ]; then
+      if [ -x "/usr/local/lib/exim4/nonzero_paniclog_hook" ]; then
+        /usr/local/lib/exim4/nonzero_paniclog_hook
+      fi
+      if [ -z "$E4BCD_PANICLOG_NOISE" ] || grep -vq "$E4BCD_PANICLOG_NOISE" /var/log/exim4/paniclog; then
+        log_this "ALERT: exim paniclog /var/log/exim4/paniclog has non-zero size, mail system possibly broken"
+        if ! printf "Subject: exim paniclog on %s has non-zero size\nTo: root\n\nexim paniclog /var/log/exim4/paniclog on %s has non-zero size, mail system might be broken" "$(hostname --fqdn)" "$(hostname --fqdn)" | exim4 root; then
+          log_this "PANIC: sending out e-mail warning has failed, exim has non-zero return code"
+        fi
       fi
     fi
+    touch /var/lib/exim4/paniclog.timestamp
   fi
 fi
 

Reply via email to