I attached the changed files, but forgot to attach the patch file itself. Here it is.
>From 31217b14bb2ca6b06797ee26adf6957e55b445dd Mon Sep 17 00:00:00 2001
From: Ken Neighbors <k...@nsds.com>
Date: Wed, 28 Apr 2010 22:34:27 -0700
Subject: Use "nice" to lower the priority of the AWStats processes when
 updating databases and generating static html reports from cron.

---
 debian/buildstatic.sh  |    3 ++-
 debian/default/awstats |    5 +++++
 debian/update.sh       |    4 +++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/debian/buildstatic.sh b/debian/buildstatic.sh
index ca09cc7..8af4c83 100755
--- a/debian/buildstatic.sh
+++ b/debian/buildstatic.sh
@@ -14,6 +14,7 @@ BUILDSTATICPAGES=/usr/share/awstats/tools/awstats_buildstaticpages.pl
 [ -f $AWSTATS -a -f $BUILDSTATICPAGES ] || exit 1
 [ -r "$DEFAULT" ] && . "$DEFAULT"
 
+NICE=${AWSTATS_NICE:-10}
 ENABLE=${AWSTATS_ENABLE_BUILDSTATICPAGES:-no}
 if [ "$ENABLE" != "yes" ]; then
   exit 0
@@ -30,7 +31,7 @@ do
   m=`date +%m`
   mkdir -p /var/cache/awstats/$c/$Y/$m/
   AL=${AWSTATS_LANG:-en}
-  if ! $BUILDSTATICPAGES \
+  if ! nice -n $NICE $BUILDSTATICPAGES \
     -config=$c \
 	-year=$Y \
 	-month=$m \
diff --git a/debian/default/awstats b/debian/default/awstats
index d8830cc..ac8c320 100644
--- a/debian/default/awstats
+++ b/debian/default/awstats
@@ -1,5 +1,10 @@
 # AWStats configuration options
 
+# This variable controls the scheduling priority for updating AWStats
+# datafiles and for generating static html reports.  Normal priority
+# is 0 and a lower priority is 10.  See "man nice" for more info.
+AWSTATS_NICE=10
+
 # This variable controls whether to create static html reports every
 # night in /var/cache/awstats/.  Set to "yes" or "no".
 AWSTATS_ENABLE_BUILDSTATICPAGES="no"
diff --git a/debian/update.sh b/debian/update.sh
index 11a8e03..2dcf647 100755
--- a/debian/update.sh
+++ b/debian/update.sh
@@ -11,6 +11,8 @@ DEFAULT=/etc/default/awstats
 AWSTATS=/usr/lib/cgi-bin/awstats.pl
 
 [ -f $AWSTATS ] || exit 1
+[ -r "$DEFAULT" ] && . "$DEFAULT"
+NICE=${AWSTATS_NICE:-10}
 
 cd /etc/awstats
 
@@ -19,7 +21,7 @@ for c in awstats \
          `/bin/ls -1 awstats.*.conf 2>/dev/null | \
           /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
 do
-  if ! $AWSTATS -config=$c -update >$TMPFILE 2>&1; then
+  if ! nice -n $NICE $AWSTATS -config=$c -update >$TMPFILE 2>&1; then
     # an error occurred
     cat $TMPFILE >&2
   fi
-- 
1.5.6.5

Reply via email to