The accounting system utility allows you to collect and report on individual, group, and Workload Manager (WLM) class use of various system resources.
This accounting information can be used to bill users for the system resources they utilize, and to monitor selected aspects of the system operation. To assist with billing, the accounting system provides the resource-usage totals defined by members of the adm group, and, if the chargefee command is included, factors in the billing fee.
The accounting system also provides data to assess the adequacy of current resource assignments, set resource limits and quotas, forecast future needs, and order supplies for printers and other devices.
The following information should help you understand how to implement the accounting utility in your system:
For data to be collected automatically, a member of the adm group needs to follow the procedures described in "Setting Up an Accounting System". These procedures enable the cron daemon to run the commands that generate data on:
The system writes a record of each session and process after they are completed. These records are converted into total accounting (tacct) records arranged by user and merged into a daily report. Periodically, the daily reports are combined to produce totals for the defined fiscal period. Methods for collecting and reporting the data and the various accounting commands and files are discussed in the following sections.
Although most of the accounting data is collected and processed automatically, a member of the adm group can enter certain commands from the keyboard to obtain specific information. These commands are discussed in Keyboard Commands.
There are several types of accounting data:
They are described in the following sections.
Connect-time data is collected by the init command and the login command. When you log in, the login program writes a record in the /etc/utmp file. This record includes your user name, the date and time of the login, and the login port. Commands, such as who, use this file to find out which users are logged into the various display stations. If the /var/adm/wtmp connect-time accounting file exists, the login command adds a copy of this login record to it.
When your login program ends (normally when you log out), the init command records the end of the session by writing another record in the /var/adm/wtmp file. Logout records differ from login records in that they have a blank user name. Both the login and logout records have the form described in the utmp.h file.
The acctwtmp command also writes special entries in the /var/adm/wtmp file concerning system shutdowns and startups.
For more information, see Connect-Time Reports.
The system collects data on resource usage for each process as it runs, including:
The accton command records these data in a specified file, usually the /var/adm/pacct file.
Related commands are the startup command, the shutacct command, the dodisk command, the ckpacct command, and the turnacct command.
For more information, see Reporting Accounting Data.
Much accounting information is collected as the resources are consumed. The dodisk command, run as specified by the cron daemon, periodically writes disk-usage records for each user to the /var/adm/acct/nite/dacct file. To accomplish this, the dodisk command calls other commands. Depending upon the thoroughness of the accounting search, the diskusg command or the acctdusg command can be used to collect data. The acctdisk command is used to write a total accounting record. The total accounting record, in turn, is used by the acctmerg command to prepare the daily accounting report.
The dodisk command charges a user for the links to files found in the user's login directory and evenly divides the charge for each file between the links. This distributes the cost of using a file over all who use it and removes the charges from users when they relinquish access to a file.
For more information, see Disk-Usage Accounting Report.
The collection of printer-usage data is a cooperative effort between the enq command and the queuing daemon. The enq command enqueues the user name, job number, and the name of the file to be printed. After the file is printed, the qdaemon command writes an ASCII record to a file, usually the /var/adm/qacct file, containing the user name, user number, and the number of pages printed. You can sort these records and convert them to total accounting records.
For more information, see Printer-Usage Accounting Report.
You can enter the chargefee command to produce an ASCII total accounting record in the /var/adm/fee file. This file will be added to daily reports by the acctmerg command.
For more information, see Fee Accounting Report.
After the various types of accounting data are collected, the records are processed and converted into reports.
Accounting commands automatically convert records into scientific notation when numbers become large. A number is represented in scientific notation in the following format:
Basee+Exp
Basee-Exp
which is the number equal to the Base number multiplied by 10 to the +Exp or -Exp power. For example, the scientific notation 1.345e+9 is equal to 1.345x109, or 1,345,000,000. And the scientific notation 1.345e-9 is equal to 1.345x10-9 or, 0.000000001345.
The runacct command calls two commands, acctcon1 and acctcon2, to process the login, logout, and system-shutdown records that collect in the/var/adm/wtmp file. The acctcon1 command converts these records into session records and writes them to the /var/adm/acct/nite/lineuse file. The acctcon2 command then converts the session records into a total accounting record, /var/adm/logacct, that the acctmerg command adds to daily reports.
If you run the acctcon1 command from the command line, you must include the -l flag to produce the line-use report, /var/adm/acct/nite/lineuse. To produce an overall session report for the accounting period, /var/adm/acct/nite/reboots, use the acctcon1 command with the -o flag.
The lastlogin command produces a report that gives the last date on which each user logged in.
Two commands process the billing-related data that was collected in the /var/adm/pacct or other specified file. The acctprc1 command translates the user ID into a user name and writes ASCII records containing the chargeable items (prime and non-prime CPU time, mean memory size, and I/O data). The acctprc2 command transforms these records into total accounting records that are added to daily reports by the acctmerg command.
Process accounting data also provides information that you can use to monitor system resource usage. The acctcms command summarizes resource use by command name. This provides information on how many times each command was run, how much processor time and memory was used, and how intensely the resources were used (also known as the hog factor). The acctcms command produces long-term statistics on system utilization, providing information on total system usage and the frequency with which commands are used.
The acctcom command handles the same data as the acctcms command, but provides detailed information about each process. You can display all process accounting records or select records of particular interest. Selection criteria include the load imposed by the process, the time period when the process ended, the name of the command, the user or group that invoked the process, the name of the WLM class the proces belonged to, and the port at which the process ran. Unlike other accounting commands, acctcom can be run by all users.
The disk-usage records collected in the /var/adm/acct/nite/dacct file are merged into the daily accounting reports by the acctmerg command.
The ASCII record in the /var/adm/qacct file can be converted to a total accounting record to be added to the daily report by the acctmerg command.
If you used the chargefee command to charge users for services such as file restores, consulting, or materials, an ASCII total accounting record is written in the /var/adm/fee file. This file is added to the daily reports by the acctmerg command.
Raw accounting data on connect-time, processes, disk usage, printer usage, and fees to charge are merged into daily reports by the acctmerg command. Called by the runacct command as part of its daily operation, the acctmerg command produces the following:
The acctmerg command can convert records between ASCII and binary formats and merge records from different sources into a single record for each user.
Called by the cron daemon, the monacct command produces the following:
The accounting commands function several different ways. Some commands:
Several commands usually run by the cron daemon automatically collect accounting data.
Other commands are run automatically by procedures other than the cron daemon:
A member of the adm group can enter the following commands from the keyboard:
The two main accounting directories are the /usr/sbin/acct directory, where all the C language programs and shell procedures needed to run the accounting system are stored, and the /var/adm directory, which contains the data, report and summary files.
The accounting data files belong to members of the adm group, and all active data files (such as wtmp and pacct) reside in the adm home directory /var/adm.
Files in the /var/adm directory are:
Report and summary files reside in a /var/adm/acct subdirectory. You must create the following subdirectories before the accounting system is enabled. See "Setting Up an Accounting System" for more information.
The following report and summary files, produced by the runacct command, are of particular interest:
active | Used by the runacct command to record progress and print warning and error messages. The file active. mmdd is a copy of the active file made by the runacct program after it detects an error. |
cms | ASCII total command summary used by the prdaily command. |
ctacct.mmdd | Connect total accounting records. |
ctmp | Connect session records. |
daycms | ASCII daily command summary used by the prdaily command. |
daytacct | Total accounting records for one day. |
dacct | Disk total accounting records, created by the dodisk command. |
accterr | Diagnostic output produced during the execution of the runacct command. |
lastdate | Last day the runacct executed, in date +%m%d format. |
lock1 | Used to control serial use of the runacct command. |
lineuse | tty line usage report used by the prdaily command. |
log | Diagnostic output from the acctcon1 command. |
logmmdd | Same as log after the runacct command detects an error. |
reboots | Contains beginning and ending dates from wtmp, and a listing of system restarts. |
statefile | Used to record the current state during execution of the runacct command. |
tmpwtmp | wtmp file corrected by the wtmpfix command. |
wtmperror | Contains wtmpfix error messages. |
wtmperrmmdd | Same as wtmperror after the runacct command detects an error. |
wtmp.mmdd | Contains previous day's wtmp file. Removed during the cleanup of runacct command. |
cms | Total command summary file for the current fiscal period, in binary format. |
cmsprev | Command summary file without the latest update. |
daycms | Command summary file for the previous day, in binary format. |
lastlogin | File created by the lastlogin command. |
pacct.mmdd | Concatenated version of all pacct files for mmdd. This file is removed after system startup by the remove command. |
rprtmmdd | Saved output of the prdaily command. |
tacct | Cumulative total accounting file for the current fiscal period. |
tacctprev | Same as tacct without the latest update. |
tacctmmdd | Total accounting file for mmdd. |
Accounting file output and formats are summarized in the following.
wtmp | Produces the active process accounting file. The format of the wtmp file is defined in the utmp.h file. |
ctmp | Produces connect session records. The format is described in the ctmp.h file. |
pacct* | Produces active process accounting records. The format of the output is defined in the /usr/include/sys/acct.h file. |
Spacct* | Produces process accounting files for mmdd during the running of the runacct command. The format of these files is defined in the sys/acct.h file. |
daytacct | Produces total accounting records for one day. The format of the file is defined in the tacct file format. |
sum/tacct | Produces binary file that accumulates each day's command summaries. The format of this file is defined in the /usr/include/sys/acct.h header file. |
ptacct | Produces concatenated versions of pacct files. The format of these files are defined in the tacct file. |
ctacct | Produces connect total accounting records. The output of this file is defined in the tacct file. |
cms | Produces total accounting command summary used by the prdaily command, in binary format. The ASCII version is nite/cms. |
daycms | Daily command summary used by the prdaily command, in binary format. The ASCII version is nite/daycms. |