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.
The following commands need to be run as root:
- For each file system that you wish to have monitored by the night jobs, add
account = trueto the desired file system entry in the /etc/filesystems file. An example is shown in Listing 7.
Listing 7. Adding
account = trueto the /etc/filesystems file
/home: dev = /dev/hd1 vol = "/home" mount = true check = true free = false vfs = jfs log = /dev/hd8 account = true
- 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.
- 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.
You can generate a report of the amount of space used by users of a file system with
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.
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.