Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
  Previous   Contents   Next 
   
 
Chapter 7

Extended Accounting

If workloads are labeled and separated by using the project and task facilities that are described in Chapter 6, Projects and Tasks, you can monitor resource consumption by workloads that are running on the system. You can use the extended accounting subsystem to capture a detailed set of resource consumption statistics on both processes and tasks, and label the usage records with the project for which the work was done.

To begin using extended accounting, see "How to Activate Extended Accounting for Processes and Tasks".

Overview

Before you can apply resource management mechanisms, you must first be able to characterize the resource consumption demands that various workloads place on a system. The extended accounting facility in the Solaris operating environment provides a flexible way to record resource consumption on a task or process basis. This facility is unlike online monitoring tools, which permit measurement of system usage in real time. Extended accounting enables you to examine historical usage and make assessments of capacity requirements for future workloads.

With extended accounting data available, you can develop or purchase software for resource chargeback, workload monitoring, or capacity planning.

How Extended Accounting Works

The extended accounting facility in the Solaris environment uses a versioned, extensible file format to contain accounting data. Files that use this data format can be accessed or created by using the API that is provided in the included library, libexacct. These files can then be analyzed on any platform with extended accounting enabled, and their data can be used for capacity planning and chargeback.

If extended accounting is active, statistics are gathered that can be examined by the libexacct API. libexacct allows examination of the exacct files either forward or backward. The API supports third-party files that are generated by libexacct as well as those files that are created by the kernel.

With extended accounting enabled, the task tracks the aggregate resource usage of its member processes. A task accounting record is written at task completion. Interim records can also be written. For more information on tasks, see Chapter 6, Projects and Tasks.

Figure 7-1 Task Tracking With Extended Accounting Activated

Extensible Format

The extended accounting format is substantially more extensible than the SunOS™ legacy system accounting software format (see "What is System Accounting?" in System Administration Guide: Advanced Administration). Extended accounting permits accounting metrics to be added and removed from the system between releases, and even during system operation.


Note - Both extended accounting and legacy system accounting software can be active on your system at the same time.


exacct Records and Format

Routines that allow exacct records to be created serve two purposes.

  • To enable third-party exacct files to be created

  • To enable the creation of tagging records to be embedded in the kernel accounting file by using the putacct system call (see getacct(2))

The format permits different forms of accounting records to be captured without requiring that every change be an explicit version change. Well-written applications that consume accounting data must ignore records they do not understand.

The libexacct library converts and produces files in the exacct format. This library is the only supported interface to exacct format files.

Extended Accounting Configuration

The /etc/acctadm.conf file contains the current extended accounting configuration. The file is edited through the acctadm interface, not by the user.

The directory /var/adm/exacct is the standard location for placing extended accounting data. You can use the acctadm(1M) command to specify a different location for the process and task accounting-data files.

Commands Used With Extended Accounting

Command

Description

acctadm(1M)

Modifies various attributes of the extended accounting facility, stops and starts extended accounting, and is used to select accounting attributes to track for processes and tasks.

wracct(1M)

Writes extended accounting activity for active processes and tasks.

lastcomm(1)

Displays previously invoked commands. lastcomm can consume either standard accounting-process data or extended-accounting process data.

For information on commands that are associated with tasks and projects, see "Commands Used to Administer Projects and Tasks".

Using Extended Accounting Functionality

How to Activate Extended Accounting for Processes and Tasks

To activate the extended accounting facility for tasks and processes, use the acctadm(1M) command. The optional final parameter to acctadm indicates whether the command should act on the process or the system task accounting components of the extended account facility.

  1. Become superuser.

  2. Activate extended accounting for processes.

    # acctadm -e extended -f /var/adm/exacct/proc process 
  3. Activate extended accounting for tasks.

    # acctadm -e extended,mstate -f /var/adm/exacct/task task

How to Activate Extended Accounting With a Startup Script

Activate extended accounting on an ongoing basis by linking the /etc/init.d/acctadm script into /etc/rc2.d.

# ln -s /etc/init.d/acctadm /etc/rc2.d/Snacctadm
# ln -s /etc/init.d/acctadm /etc/rc2.d/Knacctadm

The n variable is replaced by a number.

See "Extended Accounting Configuration" for information on accounting configuration.

How to Display Extended Accounting Status

Type acctadm without arguments to display the current status of the extended accounting facility.

# acctadm
                 Task accounting: active
            Task accounting file: /var/adm/exacct/task
          Tracked task resources: extended,mstate
        Untracked task resources: host
              Process accounting: active
         Process accounting file: /var/adm/exacct/proc
       Tracked process resources: extended
     Untracked process resources: host,mstate

In the previous example, system task accounting is active in extended mode and mstate mode. Process accounting is active in extended mode.


Note - In the context of extended accounting, microstate (mstate) refers to the extended data, associated with microstate process transitions, that is available in the process usage file (see proc(4)). This data provides much more detail about the activities of the process than basic or extended records.


How to View Available Accounting Resources

Available resources can vary from system to system, and from platform to platform. Use the -r option to view the available accounting resources on the system.

# acctadm -r
process:
extended pid,uid,gid,cpu,time,command,tty,projid,taskid,ancpid,wait-status,flag
basic    pid,uid,gid,cpu,time,command,tty,flag
task:
extended taskid,projid,cpu,time,host,mstate,anctaskid
basic    taskid,projid,cpu,time

How to Deactivate Process and Task Accounting

To deactivate process and task accounting, turn off each of them individually.

  1. Become superuser.

  2. Turn off process accounting.

    # acctadm -x process 
  3. Turn off task accounting.

    # acctadm -x task
  4. Verify that task accounting and process accounting have been turned off.

    # acctadm
                     Task accounting: inactive
                Task accounting file: none
              Tracked task resources: extended,mstate
            Untracked task resources: host
                  Process accounting: inactive
             Process accounting file: none
           Tracked process resources: extended
         Untracked process resources: host,mstate
 
 
 
  Previous   Contents   Next