PAGEFLOP
FORWARD
SELECTOR
SELAGAIN
WRONGSEL
YOUR SELECTION IS NOT IN THE 0 - #SELIMIT RANGE Please try again
GO
Copyright CourseWare Technologies Inc. 1985-1988
Lesson - 3
THE UNIX ACCOUNTING SYSTEM
MENU
Accounting|Topics to Learn|3-0|11,52
# Topic
--- -------
1 - Setting Up the Accounting System
2 - Activating and Deactivating the Accounting System
3 - The Accounting Summary Files
4 - Producing Reports
5 - Charging the Accounts
6 - The acctcom Command
6 - Reporting I/O Statistics
7 - The System Activity Package
7 - Lesson Review
8 - Lesson Review
0 - Return to the Main Menu
P1
Accounting|Setting Up the Accounting System|3-1.1|10,56
The UNIX accounting system is a sophisticated
collection of programs that provides the means to
collect per-process resource utilization data,
record connect sessions, monitor disk utilization,
and charge fees to specific logins.
The information produced by the accounting system
is used to keep track of system usage and performance.
The UNIX distribution does not include the full set of
accounting software; however, the discussion is included
for interested UNIX users.
P2
Accounting|Setting Up the Accounting System|3-1.2|8,54
Because the accounting system consumes a
significant amount of disk space and some CPU time,
it must be used for a purpose rather than a whim.
For this reason, the accounting system does not
start automatically when you set up your UNIX system.
You have to take certain steps to initiate the process.
P3
Accounting|Setting Up the Accounting System|3-1.3|8,58
The procedure for setting up the accounting system
consists of the following steps:
1. create an adm user id,
2. create a system administrator's directory: /usr/adm,
3. create accounting directories used by the accounting
system, and
4. put the accounting maintenance commands into the
/etc/rc and /usr/lib/crontab files.
Accounting|Setting Up the Accounting System|3-1.3|11,54
The procedure for setting up the accounting system
consists of the following steps:
1. Make sure your kernel includes the "options SYSACCT"
and "pseudo-device sysacct" lines.
2. Create the login- and connect-time accounting file,
/usr/adm/wtmp.
3. Turn the process-resource accounting system on with
/usr/etc/accton.
4. Put the accounting maintenance commands into the
/usr/lib/crontab file.
P4
Accounting|Setting Up the Accounting System|3-1.4|9,54
First of all, set up an account for adm by
making the necessary entry in the /etc/passwd file.
For example:
/bin/csh
Create a home directory, /usr/adm, for adm and
set up the login files and proper permissions.
Accounting|Setting Up the Accounting System|3-1.4|9,54
Two types of accounting information can be recorded
automatically by your system. Each type has its own
file and its own program to analyze and/or summarize
the information in the file:
Type of information stored in file: program used
------------------- --------------- ------------
Connect-time /usr/adm/wtmp /etc/ac
Process-time /usr/adm/acct /etc/sa
P5
Accounting|Setting Up the Accounting System|3-1.5|15,54
Once the /usr/adm directory has been set up,
create the necessary accounting directories with the
necessary access permissions.
All of the above may be accomplished by entering
the following commands:
mkdir /usr/adm/acct
mkdir /usr/adm/acct/nite
mkdir /usr/adm/acct/sum
mkdir /usr/adm/acct/fiscal
chmod 755 /usr/adm /usr/adm/acct /usr/adm/acct/*
chown adm /usr/adm /usr/adm/acct /usr/adm/acct/*
chgrp 4 /usr/adm /usr/adm/acct /usr/adm/acct/*
Accounting|Setting Up the Accounting System|3-1.5|8,54
To run the accounting, your system kernel must
include the lines options SYSACCT and PSEUDO-device sysacct.
To verify this, look in your configuration file in the
/usr/sys/conf directory. (The generic configuration
file is called GENERIC; you copied that one to a name
of your choice for editing when the system was first
configured)
P6
Accounting|Setting Up the Accounting System|3-1.6|6,54
Because the accounting files grow, you have to
make sure that they do not become too big. The
check process accounting command will
check the size of the accounting files and compresses
the information in them. To make sure this happens
automatically, include the following command line
in the /usr/lib/crontab file:
/bin/su - adm -c /usr/lib/acct/ckpacct
Accounting|Setting Up the Accounting System|3-1.6|6,54
All the executables for the accounting system
reside in the /usr/etc/ directory.
All the reports generated by the accounting system
will be in the /usr/adm directory.
P7
Accounting|Setting Up the Accounting System|3-1.7|14,54
All the executables for the accounting system reside
in the /usr/lib/acct directory.
All the reports generated by the accounting system
will be in the directories below /usr/adm, i.e.:
/usr/adm
|
acct
|
-------------------
| | |
nite sum fiscal
P8
Accounting|Activating the Accounting System|3-2.1|11,54
Once the accounting directories have been set up,
the command for activating the accounting system is:
/usr/lib/acct/startup
To make sure that this happens automatically once
the system goes to multi-user mode put the following
line into the /etc/rc file:
/bin/su - adm -c /usr/lib/acct/startup
Accounting|Activating the Accounting System|3-2.1|12,54
To activate the process-resource system accounting
summarized by the ac utility, you need to start the
accounting with the /usr/etc/accton command. This will
cause the information for every process executed to be
placed at the end of the file /usr/adm/acct. The
syntax is:
/usr/etc/accton [filename]
You can supply a filename if you wish to put the
information in a different file. (The filename must
already exist, however.)
P9
Accounting|Activating the Accounting System|3-2.2|3,54
Accounting may also be turned on with the
command:
/usr/lib/acct/accton
To start up the limited UNIX accounting system, use
the command:
/etc/accton
Accounting|Activating the Accounting System|3-2.2|9,52
The login/connect-time accounting file /usr/adm/wtmp
is maintained by the init and login programs.
However, neither of these programs will create this
file, so if it does not exist on your system, you'll
have to create it as an empty file.
This file will continue to grow without a limit to
its size, so you should periodically clean it out.
P10
Accounting|Deactivating the Accounting System|3-2.3|8,58
The command that will deactivate the accounting system is:
/usr/lib/acct/shuttacct.
To make sure that this happens automatically when the
system goes to singe-user mode, you may put the above
command into the /etc/shutdown file.
Accounting|Deactivating the Accounting System|3-2.3|6,54
To deactivate the limited UNIX accounting system
use the command:
/etc/accton
as a toggle.
Accounting|Deactivating the Accounting System|3-2.3|10,57
To deactivate the process-resource accounting system,
use the command:
/etc/accton
as a toggle.
To stop the connect-time accounting system, simply
remove the /usr/adm/wtmp file.
P11
Accounting|The Accounting Summary Files|3-3.1|13,54
After your accounting system has been in use for
a few days, you can find the accounting summaries in
the directory:
/usr/adm/acct/sum
/usr/adm
The accounting summary for a particular day is
stored in the file:
/usr/adm/acct/sum/rprtmmdd
where mmdd is the month and the day of the report.
You may get a connect-time accounting summary
for each midnight to midnight period by giving the -d
option to the ac command:
/usr/etc/ac -d
P12
Accounting|The Accounting Summary Files|3-3.2|7,54
After the process has finished, the accounting
system stores information about it in the file:
/usr/adm/pacct
which is a binary file read by accounting reporting
programs.
Accounting|The Accounting Summary Files|3-3.2|9,57
By default, the accounting system stores information
about connect-time in the file:
/usr/adm/wtmp
Every time a user logs on or off, this action is recorded
in the file. This information is used by the /usr/etc/ac
program to determine how long the user was logged on to
the system.
P13
Accounting|The Accounting Summary Files|3-3.3|14,54
Information about process-time is stored in the file:
/usr/adm/acct
Using the /usr/etc/sa program causes this
information to be condensed and placed in 2 summary files:
* /usr/adm/savacct holds a count of the number of
times each command was called and the time resources
consumed.
* /usr/adm/usracct holds accounting statistics
broken down by user.
P14
Accounting|Producing Reports|3-4.1|8,52
You can print the most recent system accounting
report by typing in:
/usr/lib/acct/prdaily
The above command is the principal command for
producing daily reports.
Accounting|Producing Reports|3-4.1|10,52
You can print the most recent connect-time
accounting report by typing in:
/usr/etc/ac
You can print the most recent process-resource
accounting report by typing in:
/usr/etc/sa
P15
Accounting|Producing Reports|3-4.2|6,50
The main daily accounting shell program is:
/usr/lib/acct/runacct
It produces daily and cumulative summary files to
run with prdaily.
Accounting|Producing Reports|3-4.2|7,54
To produce a daily accounting with the ac program,
the command is:
/usr/etc/ac -d -p
where -p requests individual totals and -d requests
the totals by day.
P16
Accounting|Producing Reports|3-4.3|11,54
The command that produces disk usage summary
files that are later merged with cumulative summary
files by runacct is:
/usr/lib/acct/dodisk
The command that produces monthly accounting
summaries is:
/usr/lib/acct/monacct
P17
Accounting|Charging the Accounts|3-5.1|6,50
Once CPU time becomes a premium, you may have
to charge users for the system time that they use.
Users may be charged for connect-time, for disk
space, file restores, communication charges, etc.
P18
Accounting|Charging the Accounts|3-5.2|6,54
The utility /usr/lib/acct/chargefee lets you set
up a charge schedule for a particular user. For
example, to set a charge of 5 units for the user smith
use:
/usr/lib/acct/chargefee smith 5
Accounting|Charging the Accounts|3-5.2|5,52
If you want to charge for computing time, you
will need to edit the /usr/lib/crontab file to
include the accounting commands and tell the clock
daemon /etc/cron to execute them every day at a
specified time.
P19
Accounting|The acctcom Command|3-6.1|8,52
Several reports produced by the accounting
software are confidential; therefore, only a
limited number of users have access to them.
One command that is available to all system
users is acctcom. This command produces the
current day's accounting report.
Accounting|Reporting I/O Statistics|3-6.1|11,54
The iostat utility interactively reports I/O
statistics, including:
* the number of characters read and written to
terminals per second,
* the number of transfers per second per disk,
* the number of kilobytes transferred per second
per disk,
* the number of milliseconds per average seek, and
* the percentage of time the system has spent in user
mode, in niced processes, in system mode and idling.
P20
Accounting|The acctcom Command|3-6.2|8,52
The accounting data produced may be used for
processing optimization, for charging users for
computer time used, etc.
You can tune the system parameters and set
process priorities based on the data produced by
the acctcom command.
Accounting|Reporting I/O Statistics|3-6.2|9,54
An optional interval argument causes iostat to
report once each interval of seconds. An optional
count argument restricts the number of reports. The
syntax is:
iostat [ drives ] [ interval [ count ] ]
P21
Accounting|The System Activity Package|3-7.1|11,54
The System Activity package (SA), reports system-
wide measurements including central processing unit
(CPU) utilization, disk and tape I/O activities,
terminal device activity, buffer usage, system calls,
system swapping, file-access activity, etc.
Because the system activity and load are much less
critical on a system with fewer users, the SA package
is not included with the UNIX distribution for smaller
systems.
is not included with the UNIX distribution.
P22
Accounting|The System Activity Package|3-7.2|12,54
The SA package consists of four commands:
sar - allows a user to generate system activity
reports in real time and to save system activities
in a file for later usage,
sag - displays system activity in graphical form,
sadp - samples disk activity once every second
during a specified time interval and reports disk
usage and seek distance in either tubular or
graphical form,
timex - a modified "time" command that times a
command and also reports concurrent system activity.
P23
Accounting|The System Activity Package|3-7.3|9,54
From the number of various counters managed by
UNIX (see sysinfo(4) in your manual), SA produces
various reports. For details see sar or your System
Administrator Manual.
The two shell scripts that produce the reports
/usr/adm/sa/sardd and /usr/adm/sadd (where dd
represents the day of the month) are sa1 and sa2!
P24
Accounting|The System Activity Package|3-7.4|8,54
You may activate your System Activity reporting
system by including the following lines into your
/usr/lib/crontab file:
0 * * * 0,6 su sys -c "/usr/lib/sa/sa1"
0 18-7 * * 1-5 su sys -c "/usr/lib/sa/sa1"
0 8-17 * * 1-5 su sys -c "/usr/lib/sa/sa1 1200 3"