From ben@scientia.demon.co.uk  Fri Jun 23 20:42:16 2000
Return-Path: <ben@scientia.demon.co.uk>
Received: from scientia.demon.co.uk (scientia.demon.co.uk [212.228.14.13])
	by hub.freebsd.org (Postfix) with ESMTP id 6E31837B747
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Jun 2000 20:40:40 -0700 (PDT)
	(envelope-from ben@scientia.demon.co.uk)
Received: from magnesium.scientia.demon.co.uk ([192.168.91.34] ident=exim)
	by scientia.demon.co.uk with esmtp (Exim 3.15 #1)
	id 135dCx-000CRC-00 for FreeBSD-gnats-submit@freebsd.org;
	Sat, 24 Jun 2000 00:49:59 +0100
Received: (from ben) by magnesium.scientia.demon.co.uk (Exim 3.15 #1)
	id 135dCw-000L50-00 for FreeBSD-gnats-submit@freebsd.org;
	Sat, 24 Jun 2000 00:49:58 +0100
Message-Id: <E135dCw-000L50-00@magnesium.scientia.demon.co.uk>
Date: Sat, 24 Jun 2000 00:49:58 +0100
From: Ben Smithurst <ben@scientia.demon.co.uk>
Reply-To: ben@scientia.demon.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: option to compress accounting files in /var/account
X-Send-Pr-Version: 3.2

>Number:         19483
>Category:       bin
>Synopsis:       option to compress accounting files in /var/account
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 23 20:50:00 PDT 2000
>Closed-Date:    Sun Jun 25 04:22:46 PDT 2000
>Last-Modified:  Sun Jun 25 04:23:08 PDT 2000
>Originator:     Ben Smithurst
>Release:        FreeBSD 3.4-STABLE i386
>Organization:
>Environment:

>Description:

The accounting files under /var/account can grow quite large, so it
would be nice to have an option to compress them as part of the daily
run.  I've been doing this for a while, but didn't send-pr it because I
thought people might object.  Now it's all configurable, I can't see a
problem, so the attached patch will do this.

>How-To-Repeat:

>Fix:

Index: defaults/periodic.conf
===================================================================
RCS file: /usr/cvs/src/etc/defaults/periodic.conf,v
retrieving revision 1.1
diff -u -r1.1 periodic.conf
--- periodic.conf	2000/06/23 01:18:21	1.1
+++ periodic.conf	2000/06/23 23:42:19
@@ -68,6 +68,7 @@
 
 # 310.accounting
 daily_accounting_enable="YES"				# Rotate acct files
+daily_accounting_compress="NO"				# Gzip rotated files
 
 # 320.distfile
 daily_distfile_enable="YES"				# Run rdist daily
Index: periodic/daily/310.accounting
===================================================================
RCS file: /usr/cvs/src/etc/periodic/daily/310.accounting,v
retrieving revision 1.4
diff -u -r1.4 310.accounting
--- 310.accounting	2000/06/23 01:18:23	1.4
+++ 310.accounting	2000/06/23 23:25:56
@@ -19,10 +19,28 @@
 	    echo "Rotating accounting logs and gathering statistics:"
 
 	    cd /var/account
-	    [ -f acct.2 ] && mv -f acct.2 acct.3
-	    [ -f acct.1 ] && mv -f acct.1 acct.2
-	    [ -f acct.0 ] && mv -f acct.0 acct.1
+
+	    # Delete any old files left around if the user changes from
+	    # non-compressed to compressed or vice-versa.
+	    find . -name 'acct.*' -mtime +5 -delete
+
+	    # Does the user want the files compressed?
+	    case "$daily_accounting_compress" in
+		[Yy][Ee][Ss])
+		    ext=".gz" ;;
+		*)
+		    ext="" ;;
+	    esac
+
+	    [ -f acct.2$ext ] && mv -f acct.2$ext acct.3$ext
+	    [ -f acct.1$ext ] && mv -f acct.1$ext acct.2$ext
+	    [ -f acct.0$ext ] && mv -f acct.0$ext acct.1$ext
 	    cp -pf acct acct.0
 	    sa -s >/dev/null
+
+	    case "$daily_accounting_compress" in
+		[Yy][Ee][Ss])
+		    gzip -f acct.0 ;;
+	    esac
 	fi;;
 esac

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: brian 
Responsible-Changed-When: Sat Jun 24 18:35:15 PDT 2000 
Responsible-Changed-Why:  
I'm talking to Ben about this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19483 
State-Changed-From-To: open->closed 
State-Changed-By: brian 
State-Changed-When: Sun Jun 25 04:22:46 PDT 2000 
State-Changed-Why:  
Added to -current - thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19483 
>Unformatted:
