can we have a quiet news.daily?

Florian Schlichting fschlich at CIS.FU-Berlin.DE
Tue Nov 10 11:36:29 UTC 2009


Hello Julien,

> I wanted to suggest that "nomail" => "nostat", that is to say that innstat
> should not be run by default with "nomail".

I fully agree.

> >As long as news.daily is run from cron, this is probably what one would
> >want (and certainly fine by me), but I wonder if we also need to take
> >into account the case when news.daily is run interactively (like when
> >cleaning up after a crash or data corruption), and the admin uses
> >"nomail" to get immediate feedback instead of having to wait for the
> >whole run to complete and the mail to arrive?
> 
> Well, hmmm...  "tail -f ${TEMP}" :)
> but it works when "nomail" is *not* provided.
> 
> When "nomail" is provided, the output is still sent to files and there
> is no immediate feedback.  The feature of having that immediate feedback
> does not currently exist, does it?  Is it a real need?

I don't think so. By far the most time of news.daily is spent in expire
and expireover, which are also the most interesting from a crash
recovery point of view. That output is always buffered in a file, so I
think I'll withdraw the point :-)

so, does this look like a commit:


news.daily: don't send superfluous mails when "nomail" is given

Make sure that when news.daily is called with "nomail", mail is only
sent when there is real output. Previously, there would always be
headings and empty lines useful to structure the full report, which are
now ommitted.

Also, postexec has been moved up to be included in the regular mail,
and the "nomail" definition of ${MAIL} is no longer overwritten with
the default.
---
 scripts/innreport.in  |    4 +++-
 scripts/news.daily.in |   46 +++++++++++++++++++++++++++++-----------------
 scripts/scanlogs.in   |   12 ++++++++----
 3 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/scripts/innreport.in b/scripts/innreport.in
index 6cfe6ca..71e374e 100644
--- a/scripts/innreport.in
+++ b/scripts/innreport.in
@@ -2073,7 +2073,9 @@ sub Write_all_results {
     $Title =~ s/\&/&/go;
     $Title =~ s/\</</go;
     $Title =~ s/\>/>/go;
-    print "$Title from $first_date to $last_date\n\n";
+    print "$Title from $first_date to $last_date\n\n"
+      if ((defined $$h{'default'}{'text'})
+        and ($$h{'default'}{'text'} =~ m/^true$/io));
   }
 
   if ($HTML) {
diff --git a/scripts/news.daily.in b/scripts/news.daily.in
index 9bd500f..7a70bba 100644
--- a/scripts/news.daily.in
+++ b/scripts/news.daily.in
@@ -147,7 +147,7 @@ do
 	;;
     Xnomail)
 	DOMAIL=false
-	MAIL="cut -c 1-1022 | ${SED} -e 's/^~/~~/'"
+	DOSTAT=false
 	;;
     Xnoprocbatch)
         DOPROCBATCH=false
@@ -184,8 +184,12 @@ if ${DAILY} ; then
 else
    MAILSUBJ="${HOSTNAME} intermediate Usenet report for ${DATE}"
 fi
-MAIL="cut -c 1-1022 | ${SED} -e 's/^~/~~/' | \
-    ${MAILCMD} -s '$MAILSUBJ' ${NEWSMASTER}"
+if ${DOMAIL} ; then
+    MAIL="cut -c 1-1022 | ${SED} -e 's/^~/~~/' | \
+	${MAILCMD} -s '$MAILSUBJ' ${NEWSMASTER}"
+else
+    MAIL="cut -c 1-1022 | ${SED} -e 's/^~/~~/'"
+fi
 
 ##  Sanity check.  Shouldn't we just bail out here with an error
 ##  instead of trying to patch things up?
@@ -272,14 +276,18 @@ shlock -p $$ -f ${LOCK} || {
 ##  Run any user programs.
 if [ -n "${PROGRAMS}" ] ; then
     for P in ${PROGRAMS} ; do
-	echo ''
-	echo "${P}:"
+	if ${DOMAIL} ; then
+	    echo ''
+	    echo "${P}:"
+	fi
 	eval ${P}
     done
 fi
 
 ${DOLOGS} && {
-    echo ''
+    if ${DOMAIL} ; then
+	echo ''
+    fi
     scanlogs ${SCANARG}
 }
 
@@ -491,8 +499,10 @@ fi
 
 ##  Renumber the active file.
 if ${DORENUMBER} ; then
-    echo ''
-    echo 'Renumbering active file.'
+    if ${DOMAIL} ; then
+	echo ''
+	echo 'Renumbering active file.'
+    fi
     if [ -z "${RENUMBER}" ] ;then
 	ctlinnd -s -t`wc -l <${ACTIVE}` renumber '' 2>&1
     else
@@ -520,6 +530,17 @@ ${DOSTAT} && {
     echo ''
 }
 
+##  Run any user programs.
+if [ -n "${POSTPROGRAMS}" ] ; then
+    for P in ${POSTPROGRAMS} ; do
+	if ${DOMAIL} ; then
+	    echo ''
+	    echo "${P}:"
+	fi
+	eval ${P}
+    done
+fi
+
 ##  Mail the report.
 if ${DOMAIL} ; then
     ##  Stop using the temp file, and mail captured output.
@@ -529,15 +550,6 @@ if ${DOMAIL} ; then
     rm -f ${TEMP}
 fi
 
-##  Run any user programs.
-if [ -n "${POSTPROGRAMS}" ] ; then
-    for P in ${POSTPROGRAMS} ; do
-	echo ''
-	echo "${P}:"
-	eval ${P}
-    done
-fi
-
 ##  All done
 if ${DAILY} ; then
     date >${PATHDB}/.news.daily
diff --git a/scripts/scanlogs.in b/scripts/scanlogs.in
index 071280c..50dfdb5 100644
--- a/scripts/scanlogs.in
+++ b/scripts/scanlogs.in
@@ -271,12 +271,16 @@ OLD_LOG=${OLD}/${BASE}.0
 ##  and summarize syslog information.
 BASE=`basename ${SYSLOG_NOTICE}`
 OLD_SYSLOG=${OLD}/${BASE}.0
+INNREPORT=${TMPDIR}/innreport$$
 if [ -s ${OLD_SYSLOG} -o -s ${OLD_LOG} ] ; then
-    ${PATHBIN}/innreport -f ${PATHETC}/innreport.conf ${OLD_SYSLOG} ${OLD_LOG}
-    echo ---------
-    echo ''
+    ${PATHBIN}/innreport -f ${PATHETC}/innreport.conf ${OLD_SYSLOG} ${OLD_LOG} > ${INNREPORT}
+    if [ -s ${INNREPORT} ] ; then
+        cat ${INNREPORT}
+        echo ---------
+        echo ''
+    fi
 fi
-rm -f ${OLD_LOG} ${OLD_SYSLOG}
+rm -f ${OLD_LOG} ${OLD_SYSLOG} ${INNREPORT}
 
 ##  Now that innreport has finished, we can move unwanted.log.  This
 ##  file is not reset because it keeps the count of unwanted newsgroups.


Florian



More information about the inn-workers mailing list