Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Using AIX accounting

Doug Monroe (monroe@sqnt.com), System Administration Consultant, DMA Inc.
Doug Monroe is a UNIX System Administration consultant and instructor with DMA Inc. He holds a bachelor's degree in computer science from Oregon State University, and he has been supporting various flavors of UNIX since 1984. You can reach him at monroe@sqnt.com.

Summary:  Accounting has been a part of the UNIX® operating system since the very early days. Most variants of UNIX have process and connect-time accounting available. As such, it's possible to merge accounting records in a heterogeneous environment for billing or monitoring purposes. In this tutorial, examine the various AIX® accounting types, how to enable them, how to generate reports, and how to customize the reporting information to be used for system monitoring and usage charging.

Date:  27 Feb 2007
Level:  Intermediate PDF:  A4 and Letter (429 KB | 25 pages)Get Adobe® Reader®

Activity:  17445 views
Comments:  

Disk-use accounting

Disk-use accounting provides information about the amount of disk space occupied by each user. The information is taken from the file inodes. Enabling disk-use accounting on a file system merely enables runacct to automatically collect and report this data. It can be set up on a file-system basis. The accounting information can be used to identify disk resource hogs, bill for disk usage, or to plan for future expansion. In this section, learn about how to enable and use connect-time accounting and reporting.

Enabling disk-use accounting

The following commands need to be run as root:

  1. For each file system that you wish to have monitored by the night jobs, add account = true to the desired file system entry in the /etc/filesystems file. An example is shown in Listing 7.


    Listing 7. Adding account = true to the /etc/filesystems file
                                     
    /home:
            dev       = /dev/hd1
            vol       = "/home"
            mount     = true
            check     = true
            free      = false
            vfs       = jfs
            log       = /dev/hd8
            account   = true
    

  2. Remove the /usr/lib/cron/cron.deny file and edit the /usr/lib/cron/cron.allow file. Add the user "adm" so that the user "adm" can run cron jobs.
  3. Enable the "dodisk" line in adm's crontab file by running "crontab -e adm" and uncommenting the line:
    0 23 * * * /usr/lib/acct/dodisk > /dev/console 2>&1

    This causes disk usage records to be collected to /var/adm/dtmp and total accounting records recorded to /var/adm/acct/nite/dacct nightly at 11:00PM.
    Setting "dodisk" to run once per day results in a snapshot of disk usage at that particular time. To get a report of the average disk usage throughout the day, set "dodisk" to run more frequently, such as every hour.

Disk-use accounting reporting

You can generate a report of the amount of space used by users of a file system with diskusg. The diskusg command displays the number of disk blocks used by each user for a specific file system (see Listing 8). You can specify any file system block device (not the mount point, sorry), regardless of whether the "account = true" entry has been added to the file system description or not. Specifying multiple block devices yields the sum of usage.


Listing 8. Using the diskusg command
                    
# /bin/df /home /usr/local
Filesystem    512-blocks      Free %Used    Iused %Iused Mounted on
/dev/hd1         3276800   2694768   18%      220     1% /home
/dev/lv00        6029312   1400776   77%   104066    14% /usr/local

# diskusg /dev/hd1
   0    root    46
   2    bin     1
 100    guest   1
 101    monroe  476690
 202    doug    33
 210    freeware        2

# diskusg /dev/hd1 /dev/lv00
   0    root    489286
   2    bin     1
 100    guest   1
 101    monroe  3909986
 202    doug    33
 210    freeware        485890

Notice how much disk space the monroe user is using from the last iteration of diskusg. It might be worth checking if this usage is legitimate, or if this user should clean up some.

The dodisk command running from cron creates the records necessary for runacct to merge this information into the nightly accounting report. This is in the runacct section.

5 of 12 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX
ArticleID=198387
TutorialTitle=Using AIX accounting
publish-date=02272007
author1-email=monroe@sqnt.com
author1-email-cc=