1*0Sstevel@tonic-gate#!/sbin/sh 2*0Sstevel@tonic-gate# 3*0Sstevel@tonic-gate# CDDL HEADER START 4*0Sstevel@tonic-gate# 5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*0Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*0Sstevel@tonic-gate# with the License. 9*0Sstevel@tonic-gate# 10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*0Sstevel@tonic-gate# See the License for the specific language governing permissions 13*0Sstevel@tonic-gate# and limitations under the License. 14*0Sstevel@tonic-gate# 15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*0Sstevel@tonic-gate# 21*0Sstevel@tonic-gate# CDDL HEADER END 22*0Sstevel@tonic-gate# 23*0Sstevel@tonic-gate# 24*0Sstevel@tonic-gate# Copyright 2004 Sun Microsystems, Inc. All rights reserved. 25*0Sstevel@tonic-gate# Use is subject to license terms. 26*0Sstevel@tonic-gate# 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T 29*0Sstevel@tonic-gate# All Rights Reserved 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.13 */ 33*0Sstevel@tonic-gate# 'perform disk accounting' 34*0Sstevel@tonic-gatePATH=:/usr/lib/acct:/usr/bin:/usr/sbin 35*0Sstevel@tonic-gateexport PATH 36*0Sstevel@tonic-gateif [ -f /usr/bin/uts -a /usr/bin/uts ] 37*0Sstevel@tonic-gatethen 38*0Sstevel@tonic-gate format="dev mnt type comment" 39*0Sstevel@tonic-gateelse 40*0Sstevel@tonic-gate format="special dev mnt fstype fsckpass automnt mntflags" 41*0Sstevel@tonic-gatefi 42*0Sstevel@tonic-gate_dir=/var/adm 43*0Sstevel@tonic-gate_pickup=acct/nite 44*0Sstevel@tonic-gateset -- `getopt o $*` 45*0Sstevel@tonic-gateif [ $? -ne 0 ] 46*0Sstevel@tonic-gatethen 47*0Sstevel@tonic-gate echo "Usage: $0 [ -o ] [ filesystem ... ]" >&2 48*0Sstevel@tonic-gate exit 1 49*0Sstevel@tonic-gatefi 50*0Sstevel@tonic-gatefor i in $*; do 51*0Sstevel@tonic-gate case $i in 52*0Sstevel@tonic-gate -o) SLOW=1; shift;; 53*0Sstevel@tonic-gate --) shift; break;; 54*0Sstevel@tonic-gate esac 55*0Sstevel@tonic-gatedone 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gatecd ${_dir} 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gateif [ "$SLOW" = "" ] 60*0Sstevel@tonic-gatethen 61*0Sstevel@tonic-gate if [ $# -lt 1 ] 62*0Sstevel@tonic-gate then 63*0Sstevel@tonic-gate if [ -f /usr/bin/uts -a /usr/bin/uts ] 64*0Sstevel@tonic-gate then 65*0Sstevel@tonic-gate DEVLIST=/etc/checklist 66*0Sstevel@tonic-gate else 67*0Sstevel@tonic-gate DEVLIST=/etc/vfstab 68*0Sstevel@tonic-gate fi 69*0Sstevel@tonic-gate while : 70*0Sstevel@tonic-gate do 71*0Sstevel@tonic-gate if read $format 72*0Sstevel@tonic-gate then 73*0Sstevel@tonic-gate if [ -z "$special" ] 74*0Sstevel@tonic-gate then 75*0Sstevel@tonic-gate continue 76*0Sstevel@tonic-gate elif [ `expr $special : '\(.\)'` = \# ] 77*0Sstevel@tonic-gate then 78*0Sstevel@tonic-gate continue 79*0Sstevel@tonic-gate fi 80*0Sstevel@tonic-gate if [ "$fsckpass" = "-" ] 81*0Sstevel@tonic-gate then 82*0Sstevel@tonic-gate continue 83*0Sstevel@tonic-gate fi 84*0Sstevel@tonic-gate if [ $fstype != ufs ] && [ $fstype != vxfs ] 85*0Sstevel@tonic-gate then 86*0Sstevel@tonic-gate continue 87*0Sstevel@tonic-gate fi 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate # Make sure FS is mounted 90*0Sstevel@tonic-gate if egrep -s "^${special}[ ]+${mnt}[ ]" /etc/mnttab 91*0Sstevel@tonic-gate then 92*0Sstevel@tonic-gate find $mnt -mount -print | \ 93*0Sstevel@tonic-gate acctdusg > \ 94*0Sstevel@tonic-gate `echo $dev | sed s-/-_-g`.dtmp & 95*0Sstevel@tonic-gate fi 96*0Sstevel@tonic-gate else 97*0Sstevel@tonic-gate wait 98*0Sstevel@tonic-gate break 99*0Sstevel@tonic-gate fi 100*0Sstevel@tonic-gate done < $DEVLIST 101*0Sstevel@tonic-gate if [ "`echo *.dtmp`" != "*.dtmp" ] 102*0Sstevel@tonic-gate then 103*0Sstevel@tonic-gate awk -e ' 104*0Sstevel@tonic-gate {tot[$1] += $3; if (name[$1] == "") name[$1] = "" $2} 105*0Sstevel@tonic-gateEND {for (i in tot) printf "%d\t%s\t%d\n", i, name[i], tot[i]}' *.dtmp > dtmp 106*0Sstevel@tonic-gate rm -f *.dtmp 107*0Sstevel@tonic-gate else 108*0Sstevel@tonic-gate > dtmp 109*0Sstevel@tonic-gate fi 110*0Sstevel@tonic-gate else 111*0Sstevel@tonic-gate find $* -mount -print | acctdusg > dtmp 112*0Sstevel@tonic-gate fi 113*0Sstevel@tonic-gateelse 114*0Sstevel@tonic-gate if [ $# -lt 1 ] 115*0Sstevel@tonic-gate then 116*0Sstevel@tonic-gate args="/" 117*0Sstevel@tonic-gate else 118*0Sstevel@tonic-gate args="$*" 119*0Sstevel@tonic-gate fi 120*0Sstevel@tonic-gate for i in $args; do 121*0Sstevel@tonic-gate if [ ! -d $i ] 122*0Sstevel@tonic-gate then 123*0Sstevel@tonic-gate echo "$0: $i is not a directory -- ignored" >&2 124*0Sstevel@tonic-gate else 125*0Sstevel@tonic-gate dir="$i $dir" 126*0Sstevel@tonic-gate fi 127*0Sstevel@tonic-gate done 128*0Sstevel@tonic-gate if [ "$dir" = "" ] 129*0Sstevel@tonic-gate then 130*0Sstevel@tonic-gate echo "$0: No data" >&2 131*0Sstevel@tonic-gate > dtmp 132*0Sstevel@tonic-gate else 133*0Sstevel@tonic-gate find $dir -print | acctdusg > dtmp 134*0Sstevel@tonic-gate fi 135*0Sstevel@tonic-gatefi 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gatesort +0n +1 dtmp | acctdisk > ${_pickup}/disktacct 138*0Sstevel@tonic-gatechmod 644 ${_pickup}/disktacct 139*0Sstevel@tonic-gatechown adm ${_pickup}/disktacct 140