Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 118399 - sys-process/acct : init script enhancement proposal
Summary: sys-process/acct : init script enhancement proposal
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-09 05:40 UTC by Hubert Mercier (RETIRED)
Modified: 2006-01-09 16:19 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
acct config defaults (/etc/conf.d/acct) (conf.d.acct,405 bytes, text/plain)
2006-01-09 05:42 UTC, Hubert Mercier (RETIRED)
Details
/etc/init.d/acct (init.d.acct,959 bytes, text/plain)
2006-01-09 05:43 UTC, Hubert Mercier (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hubert Mercier (RETIRED) gentoo-dev 2006-01-09 05:40:38 UTC
Hello :)

I recently had to deal with acct, and its configuration. In order to meet my needs, I made a few modifications to its init scripts and environment, and added some configuration items to it. I'd like to share these with the community, if you find them useable ?

First, I've added a configuration file to the package : /etc/conf.d/acct.

# ACCT_LOG specifies the accounting logging file.
# Remember to create it manually if it doesn't yet exist.
# Default : ACCT_LOG="/var/account/pacct"
ACCT_LOG="/var/account/pacct"

# REPORT_OPTS contains arguments for the "sa" command, used for console-reporting.
# Please run "sa --help" or "man sa" to get a description of available options.
REPORT_OPTS="--sort-real-time --list-all-names --percentage"



Then, I had to modify the /etc/init.d/acct script to deal with these new configuration items :

#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

opts="${opts} report"


depend() {
        need localmount
}


start() {
        if [ -z ${ACCT_LOG} ] ; then
                ewarn "Unable to load configuration. Please check /etc/conf.d/acct."
                return 1
        fi

        if ! [ -f ${ACCT_LOG} ] ; then
                ewarn "${ACCT_LOG} does not exists. Trying to create it automatically..."
                touch ${ACCT_LOG}
                chmod 600 ${ACCT_LOG}
        fi
        ebegin "Starting accounting"
        /usr/sbin/accton ${ACCT_LOG}
        eend ${ret}
}


stop() {
        ebegin "Stopping accton"
        /usr/sbin/accton
        eend $?
}


report() {
        if ! service_started "${myservice}" ; then
                ewarn ""
                ewarn "Service is not started. Statistics may be obsolete !"
                ewarn "If you really wish to get this information, please run :"
                ewarn ""
                ewarn "   sa ${REPORT_OPTS} ${ACCT_LOG}"
                ewarn ""
        else    sa ${REPORT_OPTS} ${ACCT_LOG}
        fi
        return $?
}


restart() {
        svc_stop
        svc_start
}


And that's all. Just a little enhancement, as you see ;-). But it allows to successfully run this tool without any further configuration, which may gain time to other users ?
Comment 1 Hubert Mercier (RETIRED) gentoo-dev 2006-01-09 05:42:35 UTC
Created attachment 76613 [details]
acct config defaults (/etc/conf.d/acct)
Comment 2 Hubert Mercier (RETIRED) gentoo-dev 2006-01-09 05:43:09 UTC
Created attachment 76614 [details]
/etc/init.d/acct
Comment 3 SpanKY gentoo-dev 2006-01-09 16:19:56 UTC
cleaned up and added to cvs, thanks