xref: /titanic_44/usr/src/cmd/acct/prdaily.sh (revision c28749e97052f09388969427adf7df641cdcdc22)
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"
35PATH=/usr/lib/acct:/usr/bin:/usr/sbin
36
37while getopts cl i
38do
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
45done
46shift `expr $OPTIND - 1`
47date=`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
53cd ${_nite}
54if [ `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
67fi
68
69if [ "$CMDEXCPT" = 1 ]
70then
71	acctcms -a -s ${_sum}/daycms | awk -f ${_lib}/ptecms.awk
72fi
73if [ "$LINEEXCPT" = 1 ]
74then
75	acctmerg -a < ${_sum}/tacct${date} | awk -f ${_lib}/ptelus.awk
76fi
77if [ "$CMDEXCPT" = 1 -o "$LINEEXCPT" = 1 ]
78then
79	exit 0
80fi
81(cat reboots; echo ""; cat lineuse) | pr -h "DAILY REPORT FOR ${_sysname}"
82
83prtacct daytacct "DAILY USAGE REPORT FOR ${_sysname}"
84pr -h "DAILY COMMAND SUMMARY" daycms
85pr -h "MONTHLY TOTAL COMMAND SUMMARY" cms
86pr -h "LAST LOGIN" -3 ../sum/loginlog
87exit 0
88