Home | History | Annotate | Download | only in acct
      1 #!/sbin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License, Version 1.0 only
      7 # (the "License").  You may not use this file except in compliance
      8 # with the License.
      9 #
     10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     11 # or http://www.opensolaris.org/os/licensing.
     12 # See the License for the specific language governing permissions
     13 # and limitations under the License.
     14 #
     15 # When distributing Covered Code, include this CDDL HEADER in each
     16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     17 # If applicable, add the following below this CDDL HEADER, with the
     18 # fields enclosed by brackets "[]" replaced with your own identifying
     19 # information: Portions Copyright [yyyy] [name of copyright owner]
     20 #
     21 # CDDL HEADER END
     22 #
     23 #	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
     24 #	  All Rights Reserved
     25 
     26 #
     27 # Copyright 1992 Sun Microsystems, Inc.  All rights reserved.
     28 # Use is subject to license terms.
     29 #
     30 
     31 #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.12	*/
     32 #	"prdaily	prints daily report"
     33 #	"last command executed in runacct"
     34 #	"if given a date mmdd, will print that report"
     35 PATH=/usr/lib/acct:/usr/bin:/usr/sbin
     36 
     37 while getopts cl i
     38 do
     39 	case $i in
     40 	c)	CMDEXCPT=1;;
     41 	l)	LINEEXCPT=1;;
     42 	?)	echo Usage: prdaily [-c] [-l] [mmdd] >&2
     43 		exit 2;;
     44 	esac
     45 done
     46 shift `expr $OPTIND - 1`
     47 date=`date +%m%d`
     48 _sysname="`uname -n`"
     49 _nite=/var/adm/acct/nite
     50 _lib=/usr/lib/acct
     51 _sum=/var/adm/acct/sum
     52 
     53 cd ${_nite}
     54 if [ `expr "$1" : [01][0-9][0-3][0-9]` -eq 4 -a "$1" != "$date" ]; then
     55 	if [ "$CMDEXCPT" = "1" ]
     56 	then
     57 		echo "Cannot print command exception reports except for `date '+%h %d'`" >&2
     58 		exit 5
     59 	fi
     60 	if [ "$LINEEXCPT" = "1" ]
     61 	then
     62 		acctmerg -a < ${_sum}/tacct$1 | awk -f ${_lib}/ptelus.awk
     63 		exit $?
     64 	fi
     65 	cat ${_sum}/rprt$1
     66 	exit 0
     67 fi
     68 
     69 if [ "$CMDEXCPT" = 1 ]
     70 then
     71 	acctcms -a -s ${_sum}/daycms | awk -f ${_lib}/ptecms.awk
     72 fi
     73 if [ "$LINEEXCPT" = 1 ]
     74 then
     75 	acctmerg -a < ${_sum}/tacct${date} | awk -f ${_lib}/ptelus.awk
     76 fi
     77 if [ "$CMDEXCPT" = 1 -o "$LINEEXCPT" = 1 ]
     78 then
     79 	exit 0
     80 fi
     81 (cat reboots; echo ""; cat lineuse) | pr -h "DAILY REPORT FOR ${_sysname}"  
     82 
     83 prtacct daytacct "DAILY USAGE REPORT FOR ${_sysname}"  
     84 pr -h "DAILY COMMAND SUMMARY" daycms
     85 pr -h "MONTHLY TOTAL COMMAND SUMMARY" cms 
     86 pr -h "LAST LOGIN" -3 ../sum/loginlog  
     87 exit 0
     88