accounting: ac
1
1 1 `ac'
1 ******
1
1 The `ac' command prints out a report of connect time (in hours) based
1 on the logins/logouts in the current `wtmp' file. A total is also
1 printed out.
1
1 The accounting file `wtmp' is maintained by `init' and `login'.
1 Neither of these programs creates the file; if the file is not there,
1 no accounting is done. To begin accounting, create the file with a
1 length of zero. Note that the `wtmp' file can get really big, really
1 fast. You might want to trim it every once and a while.
1
1 GNU `ac' works nearly the same u*x `ac', though it's a little
1 smarter in its printing out of daily totals--it actually prints _every_
1 day, rather than skipping to the date of the next entry in the `wtmp'
1 file.
1
1 1.1 Flags
1 =========
1
1 All of the original `ac''s options have been implemented, and a few have
1 been added. Normally, when `ac' is invoked, the output looks like this:
1 total 93867.14
1 where total is the number of hours of connect time for every entry in
1 the `wtmp' file. The rest of the flags modify the output in one way or
1 another.
1
1 `-d'
1 `--daily-totals'
1 Print totals for each day rather than just one big total at the
1 end. The output looks like this:
1 Jul 3 total 1.17
1 Jul 4 total 2.10
1 Jul 5 total 8.23
1 Jul 6 total 2.10
1 Jul 7 total 0.30
1
1 `-p'
1 `--individual-totals'
1 Print time totals for each user in addition to the usual
1 everything-lumped-into-one value. It looks like:
1 bob 8.06
1 goff 0.60
1 maley 7.37
1 root 0.12
1 total 16.15
1
1 `PEOPLE'
1 Print out the sum total of the connect time used by all of the
1 users included in people. Note that people is a space separated
1 list of valid user names; wildcards are not allowed.
1
1 `-f FILENAME'
1 `--file FILENAME'
1 Read from the file FILENAME instead of the system's `wtmp' file.
1
1 `--complain'
1 When the `wtmp' file has a problem (a time-warp, missing record,
1 or whatever), print out an appropriate error.
1
1 `--reboots'
1 Reboot records are _not_ written at the time of a reboot, but when
1 the system restarts; therefore, it is impossible to know EXACTLY
1 when the reboot occurred. Users may have been logged into the
1 system at the time of the reboot, and many `ac''s automatically
1 count the time between the login and the reboot record against the
1 user (even though all of that time _shouldn't_ be, perhaps, if the
1 system is down for a long time, for instance). If you want to
1 count this time, include the flag. *To make `ac' behave like the
1 one that was distributed with your OS, include this flag.*
1
1 `--supplants'
1 Sometimes a logout record is not written for a specific terminal,
1 so the time that the last user accrued cannot be calculated. If
1 you want to include the time from the user's login to the next
1 login on the terminal (though probably incorrect), include this
1 flag. *To make `ac' behave like the one that was distributed with
1 your OS, include this flag.*
1
1 `--timewarps'
1 Sometimes, entries in a `wtmp' file will suddenly jump back into
1 the past without a clock change record occurring. It is
1 impossible to know how long a user was logged in when this occurs.
1 If you want to count the time between the login and the time warp
1 against the user, include this flag. *To make `ac' behave like the
1 one that was distributed with your OS, include this flag.*
1
1 `--compatibility'
1 This is shorthand for typing out the three above options.
1
1 `-a'
1 `--all-days'
1 If we're printing daily totals, print a record for every day
1 instead of skipping intervening days where there is no login
1 activity. Without this flag, time accrued during those
1 intervening days gets listed under the next day where there is
1 login activity.
1
1 `-y'
1 `--print-year'
1 Print out the year when displaying dates.
1
1 `--print-zeros'
1 If a total for any category (save the grand total) is zero, print
1 it. The default is to suppress printing.
1
1 `--debug'
1 Print verbose internal information.
1
1 `--tw-leniency VALUE'
1 Set the time warp leniency value (in seconds). Records in `wtmp'
1 files might be slightly out of order (most notably when two logins
1 occur within a one-second period - the second one gets written
1 first). By default, this value is set to 1 second. Some `wtmp''s
1 are really screwed up (Suns) and require a larger value here. If
1 the program notices this problem, time is not assigned to users
1 unless the `--timewarps' flag is used. See the Problems section
1 for more information.
1
1 `--tw-suspicious VALUE'
1 Set the time warp suspicious value (in seconds). If two records
1 in the `wtmp' file are farther than this number of seconds apart,
1 there is a problem with the wtmp file (or your machine hasn't been
1 used in a year). If the program notices this problem, time is not
1 assigned to users unless the `--timewarps' flag is used.
1
1 `-V'
1 `--version'
1 Print `ac''s version number.
1
1 `-h'
1 `--help'
1 Print `ac''s usage string and default locations of system files to
1 standard output.
1
1 1.2 Problems
1 ============
1
1 For no fault of `ac''s, if two logins occur at the same time (within a
1 second of each other), each `login' process will try to write an entry
1 to the `wtmp' file. With file system overhead, it is forseeable that
1 the entries would get written in the wrong order. GNU `ac'
1 automatically compensates for this, but some other `ac's may not...
1 beware.
1
1 The FTP Problem
1 ---------------
1
1 I've tested the standard `ac' in Ultrix 4.2 (DECstation/DECsystem),
1 SunOS 4.1.1 (Sun3, Sun4, Sparc), Mach 2.5 (Omron/Luna), and DomainOS
1 10.3 (DN3500). All of these `ac's have trouble parsing entries in
1 which the line is `ftp'XXXX (XXXX being some number). Whenever these
1 `ac's see one of these entries, they log everyone out at the time of
1 the entry.
1
1 *HOW IT HAPPENS:* if there is a user logged into the machine when an
1 ftp connection occurs, (minimally) you'll get a login record for the
1 user, a login record for the ftp connection, and the logouts for both
1 afterwards (in either order).
1
1 *TANGIBLE RESULT:* the user who was logged in gets 'logged out' at the
1 time the ftp connection begins, and none of the time spent during or
1 after the ftp connection. Therefore, when you run GNU `ac', the totals
1 will most likely be greater than those of your system's `ac' (provided
1 you specify the other flags that will make GNU `ac' behave like the
1 system's).
1
1 The Shutdown/Reboot Problem
1 ...........................
1
1 On Suns, `init' is a little screwed up. For some reason, after a
1 shutdown record is written, a reboot record is written with a time-stamp
1 _before_ the shutdown (less than 30 seconds, usually).
1
1 *TANGIBLE RESULT:* GNU `ac' will notice the problem, log everyone out
1 (you can specify if you want the time to be added to the user's total)
1 and begin a new day entry based on the time of the out-of-sync record.
1 If you try to print out daily totals, you'll notice that some days
1 might have two or more entries.
1
1 *SOLUTION:* To fix this, a timewarp leniency value has been
1 implemented. If any record is out of order by this number of seconds
1 (defaults to 60) it gets ignored. If you need to change this value (if
1 you think the totals are off because the value is too high), you can
1 change it using the `--timewarp-value' flag. The rationale for the 60
1 second default is that of all of the machines with this problem, the
1 largest timewarp was 45.
1
1 Stupid System V Machines
1 ........................
1
1 Some `ac''s on System V machines (I've tried SGI Indigo & SGI Indy)
1 forget to pay attention to the `ut_type' field in a `struct utmp'. As
1 such, they chalk up a lot of time to non-existant processes called
1 `LOGIN' or `runlevel'.
1
1 *TANGIBLE RESULT:* The amount of total time reported by the system's
1 `ac' is *really* off. Often, it's several times greater than what it
1 should be.
1
1 *SOLUTION:* GNU `ac' always pays attention to the `ut_type' record, so
1 there's no possibility of chalking up time to anything but user
1 processes.
1