UNIX per-process accounting

Fred Toth fpt at wgivax.UUCP
Wed Apr 9 05:15:53 AEST 1986


Once again, I need to tap the wisdom of the community.
Here goes:

At Washburn, we have used the UNIX accounting system as
a base for charging customers for work we do for them.

Since our people may be banging away at several different
jobs at one time, we need to know which grep, sort, ls, etc.,
goes with which customer's job.

Since a customer's job related files are always in directory
subtrees, we decided long ago that we needed to know not only
what commands were run, but WHERE ('current' directory) in the
file system they were run. We made minor changes, first in
version 7, later in 4.2, to the definition of the accounting
record (acct(5)), and the kernel routines that fill the record.
We added fields for the device and inode number of the 'current'
directory. A script that runs in off hours decides whether a
given accounting record is chargeable to a customer or not,
based on whether the current directory is in an active list.

Well, this has worked very well for years. But now we would like
to distribute some of our work to another system (Sun 3). We
don't have source. Even if we did, the same changes might not
be as simple, given vnode vs. inode problems. In any case, a
system based purely on user code would be preferable.

I'm sure some members of the community have had similar problems.

I am very interested in ideas for a better way.

Some important design considerations:

1. The existing accounting system has a lot going for it. The kernel
writes a record for every process transparently. All the interesting
numbers for the process are already there (user time, system time, etc.).

2. Our current system (device/inode added to records) is totally
transparent to the users. They don't have to do anything to make it
work. An idea that may occur to some is to have users log into and
out of jobs. This gets a big thumbs down from our users, as they
hop around among many jobs at once.

3. The current system requires no modifications to user programs.
Our in-house programs, as well as standard utilities don't have to
know about the accounting system.

A nice extension to the system that would neatly solve my problem
would be a user definable field in the accounting record, set
by an non-privileged primitive. The job number could be set by
the parent shell after each directory change, and would be inherited
by all child processes. I bet people would think of lots of interesting
uses for such a thing. Alas, for now, I need a user code solution.

My questions to you all:
Does this situation ring any familiar bells?
Who has a better way?
Any ideas for discussion?

Many thanks for your attention.

Fred Toth
Washburn Graphics, Inc.
Charlotte, NC
decvax!mcnc!unccvax!wgivax!fpt
704-334-5371



More information about the Comp.unix.wizards mailing list