Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 4855

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<HTML>
<HEAD>
<TITLE>How To Enable Process Accounting on Linux</TITLE>
</HEAD>
<BODY>
<H1>How To Enable Process Accounting on Linux</H1>
<P>
<I>Last updated: Fri Aug  8 09:25:58 HKT 1997</I>
<P>
<BR>
<H6>
Preamble: This document is copylefted by Albert M.C. Tam (bertie@scn.org). 
Permission to use, copy, distribute this document for non-commerical
purposes is hereby granted, provided that the author's / editor's name and
this notice appear in all copies and/or supporting documents; that this
document is not modified. This document is distributed in hope that it
will be useful, but WITHOUT ANY WARRANTY, either expressed or implied.
While every effort has been taken to ensure the accuracy of the
information documented herein, the author / editor / maintainer assumes NO
RESPONSIBILITY for errors, or for damages results for the use of the
information documented herein. 
</H6>
<BR>
<P>
This document describes how to enable system process accounting on a Linux
host, and the usage of various process accounting commands. It is intended
for users running kernel version greater than or equal to 1.3.73 (recently
tested on RedHat 4.1 kernel 2.0.27). Kernels older than 1.3.73 may need a 
patch in order to use the process accounting feature. 
<P>
Feel free to send any feedback or comments to <A HREF="mailto:bertie@scn.org">
bertie@scn.org</A> if you find an error, or if any information is missing. I
appreciate it.
<P>
<HR>
<P>
<H2>What is Process Accounting?</H2>
<P>
Process accounting is the method of recording and summarizing commands
executed on Linux. The modern Linux kernel is capable of keeping process
accounting records for the commands being run, the user who executed the
command, the CPU time, and much more. 
<P>
Process accounting enables you to keep detailed accounting information for
the system resources used, their allocation among users, and system
monitoring. 
<P>
<H2>Current Status of Process Accounting under Linux</H2>
<P>
Process accounting support has been integrated into the newer kernels
(version >= 1.3.73). If you are running an older kernel, you may need
some patch files. The patches are available from
<P>
<UL>
<A HREF="ftp://iguana.hut.fi/pub/linux/Kernel/process_accounting/">
ftp://iguana.hut.fi/pub/linux/Kernel/process_accounting
</A>
</UL>
<P>
<H2>Requirements for Process Accounting on Linux</H2>
<P>
<B>Kernel</B>
<P>
Linux Kernel version greater than or equal to version 1.3.73, I recommended
2.x.  The kernel source is available from
<P>
<UL>
<A HREF="http://sunsite.unc.edu/pub/Linux/kernel/v2.0">
http://sunsite.unc.edu/pub/Linux/kernel/v2.0
</A>
</UL>
<P>
<B>Process accounting software</B>
<P>
Depending on the Linux distribution you have, you may, or may not have the
process accounting software package installed on your system. If you don't 
have it, try downloading the package from
<P>
<UL>
<A HREF="http://sunsite.unc.edu/pub/Linux/system/admin/quota-acct-modified.tgz">
http://sunsite.unc.edu/pub/Linux/system/admin/quota-acct-modified.tgz
</A>
</UL>
<P>
<HR>
<P>
<H2>Process Accounting Setup on Linux</H2>
<P>
<B>1. Compile and install process accounting softwares</B>
<P>
The process accounting software package is available from
<P>
<UL>
<A HREF="http://sunsite.unc.edu/pub/Linux/system/admin/quota-acct-modified.tgz">
http://sunsite.unc.edu/pub/Linux/system/admin/quota-acct-modified.tgz
</UL>
</A>
<P>
<B>
2. Modify your system init script and turn on process accounting at boot time
</B>
<P>
Here's an example: 
<P>
<PRE>
	# Turn process accounting on. 
	if [ -x /sbin/accton ]
	then
        	/sbin/accton /var/log/pacct
        	echo "Process accounting turned on." 
	fi
</PRE>
<P>
<B>3. Create accounting record file "pacct"</B>
<P>
Your process accounting softwares will print out all commands
executed to the file /var/log/pacct by default. 
<P>
To create the accounting record file: 
<P>
<PRE>
	touch /var/log/pacct
</PRE>
<P>
This record file should be owned by root, has read-write
permission for root, and read permission for anybody else: 
<PRE>
	chown root /var/log/pacct
	chmod 0644 /var/log/pacct
</PRE>
<P>
<B>4. Reboot</B>
<P>
Now reboot your system for changes you made to take effect. 
<P>
<HR>
<P>
<H2>Miscellaneous Process Accounting Commands</H2>
<P>
<B>ac</B>
<P>
ac prints out statistics about users' connection time in hours, based on the
logins and logouts in the current /var/log/wtmp file. ac is also capable
of printing out time totals for each day (-d option), and for each user
(-p option). 
<P>
<B>accton</B>
<P>
accton is used to turn on or turn off process accounting. The file is
normally executed at system bootup or shutdown via system init scripts. 
<P>
<B>last</B>
<P>
last goes through the /var/log/wtmp file and prints out information about
connection times of users. 
<P>
<B>sa</B>
<P>
sa summarizes accounting information from previously executed commands,
software I/O operation times, CPU times, as recorded in the accounting
record file /var/account/pacct. 
<P>
<B>lastcomm</B>
<P>
lastcomm prints out the information about all previously executed
commands, recorded in /var/account/pacct. 
</BODY>
</HTML>