Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

acctcms(8)

acctcom(8)

acctcon(8)

acctmerg(8)

acctprc(8)

fwtmp(8)

printpw(8)

runacct(8)

cron(8)

acct(2)

acct(8)  —  Maintenance

OSF

NAME

acct, chargefee, ckpacct, dodisk, lastlogin, monacct, nulladm, prctmp, prdaily, prtacct, remove, shutacct, startup, turnacct − Provides accounting commands for shell scripts

SYNOPSIS

chargefee User Number

ckpacct [BlockSize]

dodisk [-o] [File ....]

lastlogin

monacct [Number]

nulladm [File ....]

prctmp File .... 

prdaily [[-l] [mmdd]] | [-c]

prtacct [-f Specification] [-v] File [’Heading’]

remove

shutacct [’Reason’]

startup

turnacct on | off | switch

DESCRIPTION

There are 13 commands in the /usr/sbin/acct/∗ group that, along with other accounting commands, permit you to obtain a wide range of system accounting records and files. When used in shell scripts, many of the acct/∗ commands permit you to produce daily accounting records and files when called by the runacct command (a command outside of the acct/∗ group). Some of the acct/∗ commands are called when system activity is interrupted and must be restarted or when active accounting files become too large; still other acct/∗ commands may be used by a system administrator to perform occasional accounting procedures. 

Most often, periodic accounting files are obtained by acct/∗ commands written to a crontabs file and which are processed by the cron daemon. These periodic accounting files consist of a collection of records that are produced at the end of any process and on a daily and monthly periodic basis. 

You may specify a prime-time period for any 24-hour weekday. The prime time period is those contiguous hours of a weekday for which premium fees might be charged for resource use. Nonprime time hours are those contiguous hours that are not defined as prime time.  Non-prime time also includes weekends and any holidays listed in the file /usr/sbin/acct/holidays. 

Recommended accounting set-up procedures include entries in the /usr/spool/cron/crontabs/adm file to run two acct/∗ commands that are usually processed on a daily basis during nonprime time: 1) the dodisk command, which invokes the generation of disk-usage accounting files and 2) the ckpacct command, which is used to check the size of the /var/adm/pacct process accounting files.  Another crontabs accounting command is monacct, which is used to produce monthly summary accounting files in the /var/adm/acct/fiscal accounting subdirectory from the daily accounting files. The following 13 commands may be used in shell scripts. 

chargefee User Number
The chargefee command is used by the system administrator to charge the number of units specified by the Number parameter to the login name specified by the User parameter. The Number value may be an integer or a decimal value. The chargefee command writes a record to the /var/adm/fee file. This information is then merged with other accounting records with the acctmerg command to create a daily /var/adm/fee report.  The chargefee command uses the printpw command to get the list of all users stored in the password database. 

ckpacct [BlockSize]
The ckpacct command is used to check the size of the active process accounting file, /var/adm/pacct. Normally, the cron daemon processes this command from the crontabs file.  When the size of the active data files exceeds the number of blocks specified by the BlockSize parameter, the ckpacct command is used to invoke the turnacct switch command to turn off process accounting. The default value for the BlockSize parameter is 500.  When the number of free disk blocks in the var file system falls below 500, the ckpacct command is used to inhibit process accounting by invoking the turnacct off command.  When at least 500 free disk blocks are again available, account processing is reactivated. This feature is sensitive to how frequently ckpacct is run.  When the environment variable MAILCOM is set to mail root adm, a mail message is sent to the super-user (root) and to adm in case of an error. 

dodisk [-o] [File ....]
The dodisk command initiates disk-usage accounting by calling the diskusg command and the acctdisk command.  When you specify the -o flag with the dodisk command, a more thorough but slower version of disk accounting by login directory is initiated with the acctdusg command. Normally, the cron
daemon runs the dodisk command. The following flag may be used with the dodisk command:

-oCalls the acctdusg command instead of the diskusg command to initiate disk accounting by login directory. 

By default, the dodisk command does disk accounting on special files recorded in the /etc/fstab file. But when you specify file names with the File parameter, disk accounting is done on only those files.  When you do not specify the -o flag, the File parameter should specify special filenames of mountable file systems. When you specify both -o and one or more File(s), File(s) should specify  mount points of mounted file systems. 

lastloginThe lastlogin command updates the /var/adm/acct/sum/loginlog file to show the last date each user logged in. Normally, the runacct procedure, running under the cron daemon, calls this command and adds the information to the daily report; however, the lastlogin command can also be entered by the system administrator. The lastlogin commands uses the printpw command to get a list of all users whose name and user ID are stored in the password database file. 

monacct [Number]
The monacct command collects daily or other periodic accounting records into summary files in the /var/adm/acct/fiscal subdirectory. After monthly summary files are produced, monacct removes the old accounting files from the /var/adm/acct/sum subdirectory and replaces them with the newly created summary files.  The cron daemon should run this command once each month on the first day of the following month or some other specified day after all the dailys have been produced. (The monacct example shows how to enter this command for the cron daemon.)  The Number parameter is a numerical value in the range 1 < n < 12 (where n is the month) that indicates the month for which daily files are processed. The default value used for the Number parameter is the current month. The monacct command stores the newly created summary files in the /var/adm/acct/fiscal subdirectory and restarts new summary files in /var/adm/acct/sum, the cumulative summaries to which daily record summaries are appended. 

nulladm [File ....]
The nulladm command creates the file specified in the File parameter, gives read (r) and write (w) permissions to the file owner and group, read (r) permission to other users, and ensures that the file owner and group is adm.  Various accounting shell procedures invoke the nulladm command.  The system administrator uses this command to set up active data files, such as the /var/adm/wtmp file. 

prctmp File ....
The system administrator may use the prctmp command to output the session record file specified by File and created by the acctcon1 command (this is normally the /var/adm/acct/nite/ctmp file). 

prdaily [[-l] [mmdd]] | [-c]
The prdaily command is invoked from the runacct shell procedure to format an ASCII file of the accounting data of the previous day. The records making up this file are located in the /var/adm/acct/sum/rprtmmdd files, where mmdd is the month and day for which the file is produced. Use the mmdd parameter to specify a date other than the current day. The following flags may be used with the prdaily command:

-cReports exceptional resource usage by command. May be used only on accounting records for the current day. 

-l [mmdd]Reports exceptional usage by login ID for the specified date. 

prtacct [-f Specification] [-v] File [’Heading’]
The prtacct command formats and displays any total accounting file specified by the File parameter; records for these files are defined by a type tacct structure in the tacct.h include file. You can enter the prtacct command to output any tacct file to the default output device. For example, you may output a daily report keyed to connect time, to process time, to disk usage, and to printer usage. To specify a title for the report, specify a name for the Heading parameter with enclosed single or double quotes. The following flags may be used with the prtacct command:

-f Specification
Selects type tacct structure members to be output, using the structure-member selection mechanism specified for the acctmerg command. 

-vProduces verbose output in which more precise notation is used for floating-point numbers. 

HeadingSpecifies a heading for report members. 

The type tacct structure defines a total accounting record format, parts of which are used by various accounting commands. Members of the type tacct structure whose data types are specified as an array of two double elements have both prime-time and nonprime values. The type tacct structure has the following members. 

uid_t ta_uid
User ID.

char ta_name[NSZ]
A field for the login name with the same number of characters NSZ as the ut_user member of the utmp ­structure. 

double ta_cpu[2]
Cumulative CPU time in minutes.

double ta_kcore[2]
Cumulative k-core time in minutes.

double ta_io[2]
Cumulative number of characters transferred in blocks of 512 bytes.

double ta_rw[2]
Cumultive number of blocks read and written.

double ta_con[2]
Cumulative connect time in minutes.

double ta_du
Cumulative disk-usage time in minutes.

long ta_qsys
Queueing system (printer) fee in number of pages.

double ta_fee
Special services fee expressed in units.

long ta_pcA count of the number of processes. 

unsigned short ta_sc
A count of the number of login sessions.

unsigned short ta_dc
A count of the number of disk samples.

removeThe remove command deletes all /var/adm/acct/sum/wtmp∗, /var/adm/acct/sum/pacct∗, and /var/adm/acct/nite/lock∗ files as part of the daily cleanup procedure called by the runacct command. 

shutacct [’Reason’]
The shutacct command turns process accounting off and adds a ’Reason’ record to the /var/adm/wtmp file. This command is usually invoked during a system shutdown. 

startupThe startup command turns on the accounting functions and adds a reason record to the /var/adm/wtmp file.  Usually it is called from the /etc/rc command file, when the system is started up. See the start-up example for the command line to add to the /etc/rc file when you do the set-up procedures. 

turnacct on | off | switch
The turnacct command provides an interface to the accton command to turn process accounting on or off, or to create a new ­/var/adm/pacctn process accounting file. This command can only be executed by a superuser or by the adm login name. Only one of the arguments on, off, or switch may be used:

onTurns process accounting on. 

offTurns process accounting off. 

switchThe switch flag is used to create a new ­/var/adm/pacctn file when the current ­/var/adm/pacctn file is too large. The suffix n (where n is a positive integer) indicates the previous active /var/adm/pacctn file.  After the currently active /var/adm/pacctn file is renamed, a new active /var/adm/pacct file is created and process accounting is restarted. 

This command is usually called by the ckpacct command, running under the cron daemon, to keep the active pacct data file down to a manageable size. 

NOTES

You should not share accounting files among nodes in a distributed environment.  Each node should have its own copy of the various accounting files. 

When you are also using the sa command, sa does not know whether information is stored in the incremental /var/adm/pacctn file or in any other ­/var/adm/pacctn summary file by the acct/∗ commands (see the turnacct command). 

EXAMPLES

     1.To charge smith for 10 units of work on a financial report, enter:

/usr/sbin/acct/chargefee smith 10

A record is created in the /var/adm/fee file, which the acctmerg command is subsequently instructed to merge with records in other accounting files to produce the daily report. 

     2.To check the size of a /var/adm/pacctn summary accounting file, add the following instruction to the ­/usr/spool/cron/crontabs/adm shell script:

5 ∗ ∗ ∗ ∗ /usr/sbin/acct/ckpacct

This example shows another instruction that the cron daemon reads and acts upon when it is included in the /usr/spool/cron/crontabs/adm shell script file. The ckpacct command is set to run at 5 minutes past every hour (5 ∗) every day. This command is only one of many accounting instructions normally passed to the cron daemon from the /usr/spool/cron/crontabs/adm shell script file. See the Guide to System Administration for details. 

     3.To initiate disk-usage accounting, add the following to the /usr/spool/cron/crontabs/adm shell script file:

0 2 ∗ ∗ 4 /usr/sbin/acct/dodisk

This example illustrates a shell script instruction that the cron daemon reads and then processes. The dodisk command runs at 2 AM (0 2) each Thursday (4). This command is one of many accounting instructions normally passed to the cron daemon from a /usr/spool/cron/crontabs/adm shell script file. See the Guide to System Administration for details. 

     4.To produce a monthly accounting report, at the beginning of each month, add the following instruction to the /usr/spool/cron/crontabs/adm file:

15 5 1 ∗ ∗ /usr/sbin/acct/monacct

This example is an instruction that the cron deamon reads and then processes. The monacct command runs at 5:15 (15 5) the first day of each month (1). This command is only one of many accounting instructions normally passed to the cron daemon from the /usr/spool/cron/crontabs/adm shell script file.  See the Guide to System Administration for details. 

     5.To turn on the accounting functions when the system is started up, add the following to the /etc/rc file:

/bin/su - adm -c /usr/sbin/acct/startup

The startup shell procedure records the time and cleans up the records produced the previous day.

FILES

/usr/sbin/acct/∗
Specifies the command path.

/usr/include/sys/acct.h
Header files defining structures used to organize accounting information.

/var/adm/fee
Accumulates the fees charged to each login name.

/var/adm/pacct
Current database file for process accounting information.

/var/adm/pacctn
Another process accounting database file, which is produced when the /var/adm/pacct file gets too large. 

/var/adm/wtmp
Login/logout database file.

/usr/sbin/acct/ptelus.awk
Shell procedure that calculates limits for exceptional usage by the login ID.

/usr/sbin/acct/ptecms.awk
Shell procedure that calculates limits of exceptional usage by command name.

/var/adm/acct/nite
Working directory that contains daily accounting database files.

/etc/fstabContains information about file systems. 

/var/adm/acct/sum
Working subdirectory that contains accounting summary database files.

RELATED INFORMATION

Commands:  acctcms(8), acctcom(8), acctcon(8), acctmerg(8), acctprc(8), fwtmp(8), printpw(8), runacct(8)

Daemons:  cron(8)

Functions:  acct(2)

Guide to System Administration

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026