accounting on Sun system
roger davis
ldgo!rbd at lamont
Sun May 7 00:13:10 AEST 1989
>We'd like to have some kind of accounting system on our Sun system such
>that we can charge people for using either the workstation (sun3) or the
>server (sun4). The information we need is something like the login time,
>cpu time, printing jobs on each workstation and the server. Can anybody
>give any information like where we can get the program and how much it is?
We have written such a beast and have managed to keep it more or less
under control for about two years at a site consisting of about fifty Suns
running SunOS 3.4 spread over three subnets, monitoring CPU usage, connect
time and printing charges. By 'more or less under control', I mean that it
all basically works, but stuff does happen from time to time (down
machines and miscellaneous network constipation) which requires operator
intervention.
The system is capable of charging different rates for different hosts
(e.g., a 3/280 with an FPA has pricier CPU ticks than a 3/50), charging
differently at different times of the day, week, or year, charging some
users (e.g., system staff) not at all, charging a user for using some
hosts (file servers) but not others (the private workstation in the user's
office), etc. ad nauseam.
The package is layered over the UNIX process and login accounting files
/usr/adm/acct and /usr/adm/wtmp and the utilities which read them, sa(8)
and ac(8), and the disk usage utility quot(8).
The remainder of this posting is a description of the more important
pieces of this puzzle from hell. If there is interest, I will arrange for
anonymous ftp. E-mail any queries to me,
Roger Davis
rbd at lamont.ldgo.columbia.edu
The network-wide system accounting package at Lamont con-
sists of several distinct programs which are run at various
times, some automatically, others manually, whose final pro-
duct is a network summary of charges to be billed to various
contracts. The integral pieces of this package are:
(1) acctd
Acctd is the accounting daemon, which is invoked at boot
time within /etc/rc on each node on the network for which
accounting statistics are to be kept. Its sole function is
to move the process accounting and login files maintained by
UNIX (/usr/adm/acct and /usr/adm/wtmp, respectively) into
/usr/adm/spool, a private spooling area located on that par-
ticular node, at certain times of the day. These files are
subsequently processed by other utilities and removed.
Acctd decides when to move these files by examining the file
/usr/adm/irs/charges, which contains information telling it
how to subdivide the day into various billing periods. Each
period is associated with a particular rate at which all
activity occuring within that period is to be charged (rate
1 is the most expensive rate, rate 2 is the next most expen-
sive, etc.). Provision is made for the declaration of spe-
cial weekly periods (to provide for lower weekend rates, for
example) and special annual holidays (like Nelson Mandela's
birthday). The files are moved at the end of each period,
and are named in such a way as to be descriptive of their
contents, their time of creation and the rate at which they
are to be charged for. For instance, ACCT.870110_3a and
WTMP.870110_3a are the first process accounting and login
files created on January 10, 1987, to be charged for at rate
3. If subsequent rate 3 files are created on the same day,
they will be named ACCT.870110_3b, WTMP.870110_3b,
ACCT.870110_3c, etc.
Note that acctd examines the charges file only when it wakes
up to move files into the spooling area. If you edit this
file and wish your changes to take effect immediately, you
must kill the acctd process and restart it. Any errors will
be written to /usr/adm/irs/acctlog.
(2) daily
Daily examines all of the files placed in the spooling area
by acctd and summarizes them by writing out one line per
user detailing the total charges for CPU usage, connect time
and paper usage, as well as the total number of disk blocks
owned in all file systems whose device names are supplied as
command-line arguments. As each file in the spool is pro-
cessed, daily makes an entry to that effect in the file
/usr/adm/irs/cleanlog.
CPU usage is determined by examining the processing account-
ing files with /usr/etc/sa. Connect time is determined by
examining the login files with /usr/etc/ac. Users who have
free connect time privilege and have remotely logged in from
machines specified in allowances file are removed from WTMP*
files. Paper usage is determined by looking in /etc/printcap
for the names of any lpr accounting files and then examining
those files. /usr/etc/quot is used to establish disk usage.
Daily examines /usr/adm/irs/charges to determine the
actual monetary charge for each service.
Since this file is private to each node, it is pos-
sible to set different CPU, connect and paper charges for
different nodes -- for example, CPU time should probably be
more expensive on file servers and nodes with an FPA. (To
allow for a network-wide disk block allowance per user, disk
charges are made at one global rate.) Any errors will be
written to /usr/adm/irs/acctlog.
(3) cleanup
The cleanup program examines the file /usr/adm/irs/cleanlog
for the names of files which may be removed from the spool-
ing area. It updates this file after removing the spool
files. It will also truncate any lpr accounting files whose
names are listed in /etc/printcap. Errors are reported in
/usr/adm/irs/acctlog.
(4) etherpimp
The etherpimp is a master processing utility that is invoked
once daily from cron on the machine which has been desig-
nated as the central accounting host. It examines the file
/usr/adm/irs/accthosts for the names of all machines on the
network from which accounting information is to be col-
lected, and then calls them up one by one via an rsh of
daily.
One record per user per host detailing CPU, connect and
paper charges is written to the binary file
/usr/adm/irs/summary along with a timestamp and the user's
account number, which is obtained from /usr/adm/irs/users.
(The account number is *not* the user-id number, but the number
of a site-specific billing contract.)
(If the etherpimp cannot find an account number, the record
will be written to /usr/adm/irs/summary.misc. It is a good
idea to examine this file periodically to track down users
who are operating without an account number.) Disk usage is
totalled across the entire network and converted to a mone-
tary charge after adjusting for any allowance declared in
/usr/adm/irs/allowances.
After all output records have been successfully appended to
the summary files, an rsh of cleanup is invoked on all
machines which have successfully communicated their informa-
tion to the etherpimp. Again, any errors will be reported in
/usr/adm/irs/acctlog.
(5) rd_summ [ -i ] [ -t ] [ -u user ] [ -d start_date ] [ -a
acct# ] summary >
Rd_summ is a simple filter which reads a summary file and
writes its ASCII equivalent on stdout. It is useful for
checking up on the daily charges incurred by a particular
user. Command-line options cause the free host information
in /usr/adm/irs/allowances to be ignored and thus force the
display of all records (-i), or display totals for a partic-
ular user (-t in conjunction with -u).
(6) split_summ -d date file_0 file_1 summary
split_summ reads a summary file and splits it into two out-
put files file_0 and file_1, with file_1 containing all
records timestamped on or after date. This is useful for
splitting up the summary file at the start of a new billing
period. Care must be taken that the new summary file is
restored to its proper location, ownership and permissions,
so that the automated nightly processing will continue to
run properly.
(7) edacct summary
Edacct is a SunView window utility which allows a summary
file to be edited. This is done by converting the binary
summary to ASCII and putting the result into a text editor
subwindow. After any desired changes are made, the contents
of the subwindow are converted back to binary format. An
additional panel subwindow provides some added functional-
ity.
(8) usage [ -i ] [-b billfile ] [ -t tapefile tapenumber ]
summary >
Usage reads a summary file and writes on its stdout the
total charges per account over the entire file. Each account
is further subdivided into the total charges incurred by
each user-id operating under that account. Contract informa-
tion is read from /usr/adm/irs/contracts. Free host infor-
mation is read from /usr/adm/irs/allowances. Specifying the
-b or -t options will cause the generation of an enscript-
able bill or the creation of a tape image suitable for pro-
cessing downtown (after conversion to EBCDIC). The -i
option, which is useful for displaying exhaustive summary
statistics, causes all free host information to be ignored.
(9) money [ all ]
Money is a shell script calling rd_summ which may be invoked
by users to determine their current charges.
Sun Release 3.4 Last change: January 1987 10
More information about the Comp.sys.sun
mailing list