 |
Index for Section 8 |
|
 |
Alphabetical listing for A |
|
 |
Bottom of page |
|
acct(8)
NAME
acct, chargefee, ckpacct, dodisk, lastlogin, monacct, nulladm, prctmp,
prdaily, prtacct, remove, shutacct, startup, turnacct - Provide 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 a number of commands in the /usr/sbin/acct directory that, along
with other accounting commands, enable you to produce a wide range of
system accounting records and files. For example, the runacct script
invokes some accounting commands and enables you to produce daily
accounting records and files. Some of the commands in the acct directory
are invoked when active accounting files become too large, and other
commands can be used by a system administrator to perform periodic
accounting operations.
Daily and monthly accounting reports can be produced by specifying commands
in the /usr/var/spool/cron/crontabs directory, which are processed by the
cron daemon. These accounting reports consist of a collection of records
that are produced at the end of any process and on a daily and monthly
periodic basis.
You can specify a prime-time period for any 24-hour weekday. Prime-time
hours are 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. Nonprime time also includes weekends
and any holidays listed in the file /usr/sbin/acct/holidays.
When you set up accounting, you can include entries in the
/usr/spool/cron/crontabs/adm file to run the following accounting commands:
ckpacct The ckpacct command checks the size of the /var/adm/pacct process
accounting files.
runacct The runacct command includes other accounting shell scripts and
commands and creates daily and monthly accounting files.
monacct The monacct command produces monthly summary accounting files in
the /var/adm/acct/fiscal accounting subdirectory from the daily
accounting files.
In addition, you can include the dodisk command in the
/usr/spool/cron/crontabs/root file. The dodisk command creates disk usage
accounting records.
The accounting commands are as follows:
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:
-o Calls 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 file names 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.
lastlogin The 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 command 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 dailies 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:
-c Reports 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.
-v Produces verbose output in which more precise notation
is used for floating-point numbers.
Heading Specifies 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-time 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]
Cumulative 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
Queuing system (printer) fee in number of pages.
double ta_fee
Special services fee expressed in units.
long ta_pc
A 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.
remove The 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.
startup The startup command turns on the accounting functions and adds a
reason record to the /var/adm/wtmp file. Usually the startup
command is invoked by the /sbin/init.d/acct script when the
system is started up.
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 be
executed only by a superuser or by the adm login name. Only one
of the arguments on, off, or switch may be used:
on Turns process accounting on.
off Turns process accounting off.
switch The 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 file:
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 System
Administration manual for details.
3. To initiate disk-usage accounting, add the following to the
/usr/spool/cron/crontabs/root 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 a.m. (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 System
Administration manual 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 daemon 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 System
Administration manual for details.
5. To turn on the accounting functions when the system is started up, add
the following to the /etc/rc.config file:
ACCOUNTING="YES"
To set the variable, use the following rcmgr command:
rcmgr set ACCOUNTING YES
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, /usr/include/utmp.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/fstab Contains 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),
cron(8), fwtmp(8), printpw(8), runacct(8), rcmgr(8), wtmpconvert(8).
Functions: acct(2)
System Administration
 |
Index for Section 8 |
|
 |
Alphabetical listing for A |
|
 |
Top of page |
|