Package: awstats Version: 6.9.5~dfsg-2 Severity: wishlist Tags: patch
The scripts run from the awstats cron job (update.sh and buildstatic.sh) do not report any errors because stdout is redirected to /dev/null. Therefore it is difficult to track down why awstats is not generating its database files. Attached is a patch that allows these scripts to report the error message in an email from cron whenever the awstats.pl program exits with a non-zero status. Detail: TMPFILE is used to record the output of awstats and awstats_buildstaticpages.pl (from both stdout and stderr). If the return status of awstats/awstats_buildstaticpages.pl is nonzero, then an error occurred and the content of TMPFILE is printed to stderr to show up in a cron email report. Note that a failure of awstats.pl/awstats_buildstaticpages.pl due to a bad config file will now no longer stop it from processing additional config files; update.sh/buildstatic.sh will continue to run awstats.pl/awstats_buildstaticpages.pl on other config files. This feature has both good and bad consequences: an error in a single config file will not interrupt processing of the remaining config files (good); but an error in awstats.local.conf (which is included in all config files) will generate a repeated error message for multiple config files (bad). I think the good outweighs the bad, but if you think that update.sh/buildstatic.sh should stop after the first error, then you can add "exit 1" after "cat $TMPFILE >&2" in both scripts. -- System Information: Debian Release: 5.0.4 APT prefers stable APT policy: (500, 'stable'), (50, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages awstats depends on: ii perl 5.10.0-19lenny2 Larry Wall's Practical Extraction Versions of packages awstats recommends: ii libnet-xwhois-perl 0.90-3 Whois Client Interface for Perl5 Versions of packages awstats suggests: pn apache2 | httpd <none> (no description available) pn libgeo-ipfree-perl <none> (no description available) pn libnet-dns-perl <none> (no description available) pn libnet-ip-perl <none> (no description available) ii liburi-perl 1.35.dfsg.1-1 Manipulates and accesses URI strin -- no debconf information
>From cf0fa60b4d7279d6dc3deae071a0ff9555823e40 Mon Sep 17 00:00:00 2001 From: Ken Neighbors <[email protected]> Date: Wed, 28 Apr 2010 09:54:58 -0700 Subject: Show error messages from cron jobs (update.sh and buildstatic.sh). --- debian/buildstatic.sh | 12 +++++++++--- debian/update.sh | 9 +++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh index 91dd4d9..9f41cbc 100755 --- a/debian/buildstatic.sh +++ b/debian/buildstatic.sh @@ -16,6 +16,7 @@ BUILDSTATICPAGES=/usr/share/awstats/tools/awstats_buildstaticpages.pl cd /etc/awstats +TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX` for c in awstats \ `/bin/ls -1 awstats.*.conf 2>/dev/null | \ /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'` @@ -24,11 +25,16 @@ do m=`date +%m` mkdir -p /var/cache/awstats/$c/$Y/$m/ AL=${AWSTATS_LANG:-en} - $BUILDSTATICPAGES \ + if ! $BUILDSTATICPAGES \ -config=$c \ -year=$Y \ -month=$m \ -lang=$AL \ -staticlinksext=${AL}.html \ - -dir=/var/cache/awstats/$c/$Y/$m/ -done >/dev/null + -dir=/var/cache/awstats/$c/$Y/$m/ >$TMPFILE 2>&1 + then + # an error occurred + cat $TMPFILE >&2 + fi +done +rm -f $TMPFILE diff --git a/debian/update.sh b/debian/update.sh index bd49d5d..11a8e03 100755 --- a/debian/update.sh +++ b/debian/update.sh @@ -14,9 +14,14 @@ AWSTATS=/usr/lib/cgi-bin/awstats.pl cd /etc/awstats +TMPFILE=`mktemp /tmp/awstats.XXXXXXXXXX` for c in awstats \ `/bin/ls -1 awstats.*.conf 2>/dev/null | \ /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'` do - $AWSTATS -config=$c -update -done >/dev/null + if ! $AWSTATS -config=$c -update >$TMPFILE 2>&1; then + # an error occurred + cat $TMPFILE >&2 + fi +done +rm -f $TMPFILE -- 1.5.6.5

