Package: sarg Version: 2.3.10-2 Severity: wishlist Dear Maintainer,
The patches below (two of which are diffs from the revised versions I proposed in bug 845455) include the following proposed changes: 1. Configuration option for number of saved logs per report type It seems to me that surely I'm not the only one who would like to keep different numbers of different types of report. At the same time, different people will have different history requirements. sarg-reports uses the same sarg.conf for all types of reports, but sarg allows override of the lastlog setting by using the --lastlog= switch. The change made in 2.3.10-2 does allow a user (should he/she wish) to pass this switch to sarg by adjusting the cron jobs which the Debian sarg package installs for sarg-reports. However, I reckon that this is a common-enough requirement to justify adding dedicated settings in sarg-reports.conf. 2. Setting of distinct temporary directory for each run of the script, per recommendation from Frederic Marchal in case of overlap of cron jobs. References: https://sourceforge.net/p/sarg/discussion/363374/thread/efb2f9e9/#3cf7 https://sourceforge.net/p/sarg/discussion/363374/thread/efb2f9e9/#7d4d I acknowledge that my "rm -rf $TMPDIR" may be a bad idea - I'm not sure how best to make that safe. Further, I suspect that my patch in the previous bug may have been faulty as I had problems applying it - I hope you could work with it and that these ones are also good enough. --------------------------<snip><Start of patch><snip>---------------------------- --- sarg-reports.proposed +++ sarg-reports.proposed-with-lastlog @@ -6,7 +6,7 @@ # - martijn # - Stas Degteff https://sourceforge.net/users/stas_degteff/ -VER=debian-sarg-2.3.10-2 +VER=debian-sarg-2.3.10-2-with-lastlog ## What is this? # sarg-reports (this file) is a simple bash script written to automate @@ -55,6 +55,9 @@ # (SARG) The sarg executable location # (CONFIG) The sarg main configuration file location # (HTMLOUT) Location where will be saved the reports +# (LASTLOGDAILY) Number of previous daily reports to keep (affects "today" and "manual" logs too) +# (LASTLOGWEEKLY) Number of previous weekly reports to keep +# (LASTLOGMONTHLY) Number of previous monthly reports to keep # (PAGETITLE) The title of main index page # (LOGOIMG) Image logo to view in main index page # (LOGOLINK) HTTP web page link of logo @@ -110,6 +113,7 @@ # TEMP Files TMPFILE=`/bin/mktemp` ERRORS="${TMPFILE}.errors" +TMPDIR=`/bin/mktemp -d` # Date Calc MANUALDATE=$2 @@ -210,10 +214,15 @@ { cat $ERRORS | grep -v "$EXCLUDELOG1" | grep -v "$EXCLUDELOG2" rm -f $TMPFILE* + rm -rf $TMPDIR } manual () { + if [ -n "$LASTLOGDAILY" ] + then + LASTLOG="--lastlog=$LASTLOGDAILY" + fi DAILYOUT=$HTMLOUT/$DAILY mkdir -p $DAILYOUT create_index_html @@ -221,43 +230,59 @@ then echo "No date given, please specify a valid date (DD/MM/YYYY)" else - $SARG -f $CONFIG -d $MANUALDATE -o $DAILYOUT ${@} ${ACCESS_LOG}* + $SARG -f $CONFIG -w $TMPDIR -d $MANUALDATE -o $DAILYOUT $LASTLOG ${@} ${ACCESS_LOG}* fi } today () { + if [ -n "$LASTLOGDAILY" ] + then + LASTLOG="--lastlog=$LASTLOGDAILY" + fi DAILYOUT=$HTMLOUT/$DAILY mkdir -p $DAILYOUT create_index_html - $SARG -f $CONFIG -d $TODAY -o $DAILYOUT ${@} ${ACCESS_LOG}* >$ERRORS 2>&1 + $SARG -f $CONFIG -w $TMPDIR -d $TODAY -o $DAILYOUT $LASTLOG ${@} ${ACCESS_LOG}* >$ERRORS 2>&1 exclude_from_log } daily () { + if [ -n "$LASTLOGDAILY" ] + then + LASTLOG="--lastlog=$LASTLOGDAILY" + fi DAILYOUT=$HTMLOUT/$DAILY mkdir -p $DAILYOUT create_index_html - $SARG -f $CONFIG -d day-1 -o $DAILYOUT ${@} ${ACCESS_LOG}* >$ERRORS 2>&1 + $SARG -f $CONFIG -w $TMPDIR -d day-1 -o $DAILYOUT $LASTLOG ${@} ${ACCESS_LOG}* >$ERRORS 2>&1 exclude_from_log } weekly () { + if [ -n "$LASTLOGWEEKLY" ] + then + LASTLOG="--lastlog=$LASTLOGWEEKLY" + fi WEEKLYOUT=$HTMLOUT/$WEEKLY mkdir -p $WEEKLYOUT create_index_html - $SARG -f $CONFIG -d week-1 -o $WEEKLYOUT ${@} ${ACCESS_LOG}* >$ERRORS 2>&1 + $SARG -f $CONFIG -w $TMPDIR -d week-1 -o $WEEKLYOUT $LASTLOG ${@} ${ACCESS_LOG}* >$ERRORS 2>&1 exclude_from_log } monthly () { + if [ -n "$LASTLOGMONTHLY" ] + then + LASTLOG="--lastlog=$LASTLOGMONTHLY" + fi MONTHLYOUT=$HTMLOUT/$MONTHLY mkdir -p $MONTHLYOUT create_index_html - $SARG -f $CONFIG -d month-1 -o $MONTHLYOUT ${@} ${ACCESS_LOG}* >$ERRORS 2>&1 + $SARG -f $CONFIG -w $TMPDIR -d month-1 -o $MONTHLYOUT $LASTLOG ${@} ${ACCESS_LOG}* >$ERRORS 2>&1 exclude_from_log } @@ -302,6 +327,7 @@ ## HISTORY: +# debian-sarg-2.3.10-2-with-lastlog - add lastlog option to keep different numbers of previous reports per type, private temporary directory # debian-sarg-2.3.10-2 - use all rotated log files, pass through options from command line # debian-sarg-? - added reports_autorm function (not used) # ... - ? ---------------------------<snip><End of patch><snip>----------------------------- --------------------------<snip><Start of patch><snip>---------------------------- --- sarg-reports.conf +++ sarg-reports.conf.proposed-with-lastlog @@ -1,6 +1,9 @@ SARG=/usr/bin/sarg CONFIG=/etc/sarg/sarg.conf HTMLOUT=/var/lib/sarg + LASTLOGDAILY=31 + LASTLOGWEEKLY=4 +LASTLOGMONTHLY=12 PAGETITLE="Access Reports on $(hostname)" LOGOIMG=/sarg/images/sarg.png LOGOLINK="http://$(hostname)/" ---------------------------<snip><End of patch><snip>----------------------------- --------------------------<snip><Start of patch><snip>---------------------------- --- sarg-reports-manpage.proposed +++ sarg-reports-manpage.proposed-with-lastlog @@ -61,6 +61,15 @@ HTMLOUT Location where will be saved the reports + LASTLOGDAILY + Set the number of previous daily/today/manual reports to keep + + LASTLOGWEEKLY + Set the number of previous weekly reports to keep + + LASTLOGMONTHLY + Set the number of previous monthly reports to keep + PAGETITLE The title of main index page ---------------------------<snip><End of patch><snip>-----------------------------