Mercurial > unleashed > wips
changeset 20619:1b4935f72a21
remove legacy accounting support
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 20 May 2019 19:46:49 -0400 |
parents | 1384e535719c |
children | 28ac1026d799 d25071fa795e |
files | FEATURES.txt share/man/man1/Makefile share/man/man1/acctcom.1 share/man/man1/sar.1 share/man/man1/timex.1 share/man/man4/Makefile share/man/man4/holidays.4 share/man/man8/Makefile share/man/man8/acct.8 share/man/man8/acctcms.8 share/man/man8/acctcon.8 share/man/man8/acctmerg.8 share/man/man8/acctprc.8 share/man/man8/acctsh.8 share/man/man8/fwtmp.8 share/man/man8/runacct.8 share/man/man8/sar.8 usr/src/Targetdirs usr/src/cmd/Adm/Makefile usr/src/cmd/Adm/sys usr/src/cmd/Makefile usr/src/cmd/Makefile.check usr/src/cmd/acct/Makefile usr/src/cmd/acct/acct.sh usr/src/cmd/acct/acctcms.c usr/src/cmd/acct/acctcom.c usr/src/cmd/acct/acctcon.c usr/src/cmd/acct/acctcon1.c usr/src/cmd/acct/acctcon2.c usr/src/cmd/acct/acctdef.h usr/src/cmd/acct/acctdisk.c usr/src/cmd/acct/acctdusg.c usr/src/cmd/acct/acctmerg.c usr/src/cmd/acct/accton.c usr/src/cmd/acct/acctprc.c usr/src/cmd/acct/acctprc1.c usr/src/cmd/acct/acctprc2.c usr/src/cmd/acct/acctwtmp.c usr/src/cmd/acct/chargefee.sh usr/src/cmd/acct/ckpacct.sh usr/src/cmd/acct/closewtmp.c usr/src/cmd/acct/dodisk.sh usr/src/cmd/acct/fwtmp.c usr/src/cmd/acct/lastlogin.sh usr/src/cmd/acct/monacct.sh usr/src/cmd/acct/nulladm.sh usr/src/cmd/acct/prctmp.sh usr/src/cmd/acct/prdaily.sh usr/src/cmd/acct/prtacct.sh usr/src/cmd/acct/ptecms.awk usr/src/cmd/acct/ptelus.awk usr/src/cmd/acct/remove.sh usr/src/cmd/acct/runacct.sh usr/src/cmd/acct/shutacct.sh usr/src/cmd/acct/startup.sh usr/src/cmd/acct/turnacct.sh usr/src/cmd/acct/utmp2wtmp.c usr/src/cmd/acct/wtmpfix.c usr/src/cmd/sa/Makefile usr/src/cmd/sa/README usr/src/cmd/sa/sa.h usr/src/cmd/sa/sa1.sh usr/src/cmd/sa/sa2.sh usr/src/cmd/sa/sadc.c usr/src/cmd/sa/sar.c usr/src/cmd/sa/sar.xml usr/src/cmd/sa/svc-sar usr/src/cmd/sa/timex.c usr/src/pkg/manifests/system-accounting-legacy.mf |
diffstat | 69 files changed, 4 insertions(+), 12946 deletions(-) [+] |
line wrap: on
line diff
--- a/FEATURES.txt Mon May 20 17:16:39 2019 -0400 +++ b/FEATURES.txt Mon May 20 19:46:49 2019 -0400 @@ -12,6 +12,7 @@ - /etc/log symlink & /var/adm/log directory - /etc/[uw]tmpx symlink - /usr/adm symlink + - legacy accounting and reporting * moved all /var/adm files to /var/log * moved /var/svc/log to /var/log/svc
--- a/share/man/man1/Makefile Mon May 20 17:16:39 2019 -0400 +++ b/share/man/man1/Makefile Mon May 20 19:46:49 2019 -0400 @@ -1,5 +1,4 @@ -MAN = acctcom.1 \ - adb.1 \ +MAN = adb.1 \ appcert.1 \ apptrace.1 \ ar.1 \ @@ -194,7 +193,6 @@ ruptime.1 \ rusers.1 \ rwho.1 \ - sar.1 \ script.1 \ sdiff.1 \ set.1 \ @@ -226,7 +224,6 @@ tftp.1 \ time.1 \ times.1 \ - timex.1 \ tip.1 \ touch.1 \ tput.1 \
--- a/share/man/man1/acctcom.1 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,346 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T -.\" Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH ACCTCOM 1 "Jan 11, 1996" -.SH NAME -acctcom \- search and print process accounting files -.SH SYNOPSIS -.LP -.nf -\fBacctcom\fR [\fB-abfhikmqrtv\fR] [\fB-C\fR \fIsec\fR] [\fB-e\fR \fItime\fR] [\fB-E\fR \fItime\fR] - [\fB-g\fR \fIgroup\fR] [\fB-H\fR \fIfactor\fR] [\fB-I\fR \fIchars\fR] [\fB-l\fR \fIline\fR] - [\fB-n\fR \fIpattern\fR] [\fB-o\fR \fIoutput-file\fR] [\fB-O\fR \fIsec\fR] [\fB-s\fR \fItime\fR] - [\fB-S\fR \fItime\fR] [\fB-u\fR \fIuser\fR] [\fIfilename\fR]... -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBacctcom\fR utility reads \fIfilename\fRs, the standard input, or -\fB/var/log/pacct\fR, in the form described by \fBacct.h\fR(3HEAD) and writes -selected records to standard output. Each record represents the execution of -one process. The output shows the \fBCOMMAND NAME\fR, \fBUSER\fR, -\fBTTYNAME\fR, \fBSTART TIME\fR, \fBEND TIME\fR, \fBREAL (SEC)\fR, \fBCPU -(SEC)\fR, \fBMEAN SIZE (K)\fR, and optionally, \fBF\fR (the -\fBfork()\fR/\fBexec()\fR flag: \fB1\fR for \fBfork()\fR without \fBexec()\fR), -\fBSTAT\fR (the system exit status), \fBHOG FACTOR\fR, \fBKCORE MIN\fR, \fBCPU -FACTOR\fR, \fBCHARS TRNSFD\fR, and \fBBLOCKS\fR \fBREAD\fR (total blocks read -and written). -.sp -.LP -A `\fB#\fR' is prepended to the command name if the command was executed with -super-user privileges. If a process is not associated with a known terminal, a -`\fB?\fR' is printed in the \fBTTYNAME\fR field. -.sp -.LP -If no \fIfilename\fR is specified, and if the standard input is associated -with a terminal or \fB/dev/null\fR (as is the case when using `\fB&\fR\&' in -the shell), \fB/var/log/pacct\fR is read; otherwise, the standard input is -read. -.sp -.LP -If any \fIfilename\fR arguments are given, they are read in their respective -order. Each file is normally read forward, that is, in chronological order by -process completion time. The file \fB/var/log/pacct\fR is usually the current -file to be examined; a busy system may need several such files of which all but -the current file are found in \fB/var/log/pacct\fIincr\fR\fR. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-a\fR\fR -.ad -.RS 18n -Show some average statistics about the processes selected. The statistics will -be printed after the output records. -.RE - -.sp -.ne 2 -.na -\fB\fB-b\fR\fR -.ad -.RS 18n -Read backwards, showing latest commands first. This option has no effect when -standard input is read. -.RE - -.sp -.ne 2 -.na -\fB\fB-f\fR\fR -.ad -.RS 18n -Print the \fBfork()\fR/\fBexec()\fR flag and system exit status columns in the -output. The numeric output for this option will be in octal. -.RE - -.sp -.ne 2 -.na -\fB\fB-h\fR\fR -.ad -.RS 18n -Instead of mean memory size, show the fraction of total available \fBCPU\fR -time consumed by the process during its execution. This "hog factor" is -computed as (total \fBCPU\fR time)/(elapsed time). -.RE - -.sp -.ne 2 -.na -\fB\fB-i\fR\fR -.ad -.RS 18n -Print columns containing the \fBI/O\fR counts in the output. -.RE - -.sp -.ne 2 -.na -\fB\fB-k\fR\fR -.ad -.RS 18n -Instead of memory size, show total kcore-minutes. -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR\fR -.ad -.RS 18n -Show mean core size (the default). -.RE - -.sp -.ne 2 -.na -\fB\fB-q\fR\fR -.ad -.RS 18n -Do not print any output records, just print the average statistics as with the -\fB-a\fR option. -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR\fR -.ad -.RS 18n -Show \fBCPU\fR factor (user-time/(system-time + user-time)). -.RE - -.sp -.ne 2 -.na -\fB\fB-t\fR\fR -.ad -.RS 18n -Show separate system and user \fBCPU\fR times. -.RE - -.sp -.ne 2 -.na -\fB\fB-v\fR\fR -.ad -.RS 18n -Exclude column headings from the output. -.RE - -.sp -.ne 2 -.na -\fB\fB-C\fR \fIsec\fR\fR -.ad -.RS 18n -Show only processes with total \fBCPU\fR time (system-time + user-time) -exceeding \fIsec\fR seconds. -.RE - -.sp -.ne 2 -.na -\fB\fB-e\fR \fItime\fR\fR -.ad -.RS 18n -Select processes existing at or before \fItime\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-E\fR \fItime\fR\fR -.ad -.RS 18n -Select processes ending at or before \fItime\fR. Using the same \fItime\fR for -both \fB-S\fR and \fB-E\fR shows the processes that existed at \fItime\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-g\fR \fIgroup\fR\fR -.ad -.RS 18n -Show only processes belonging to \fIgroup\fR. The \fIgroup\fR may be designated -by either the group \fBID\fR or group name. -.RE - -.sp -.ne 2 -.na -\fB\fB-H\fR \fIfactor\fR\fR -.ad -.RS 18n -Show only processes that exceed \fBfactor\fR, where factor is the "hog factor" -as explained in option \fB-h\fR above. -.RE - -.sp -.ne 2 -.na -\fB\fB-I\fR \fIchars\fR\fR -.ad -.RS 18n -Show only processes transferring more characters than the cutoff number given -by \fIchars\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-l\fR \fIline\fR\fR -.ad -.RS 18n -Show only processes belonging to terminal \fB/dev/term/line\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-n\fR \fIpattern\fR\fR -.ad -.RS 18n -Show only commands matching \fIpattern\fR that may be a regular expression as -in \fBregcmp\fR(3C), except \fB+\fR means one or more occurrences. -.RE - -.sp -.ne 2 -.na -\fB\fB-o\fR \fIoutput-file\fR\fR -.ad -.RS 18n -Copy selected process records in the input data format to \fIoutput-file\fR; -suppress printing to standard output. -.RE - -.sp -.ne 2 -.na -\fB\fB-O\fR \fIsec\fR\fR -.ad -.RS 18n -Show only processes with \fBCPU\fR system time exceeding \fIsec\fR seconds. -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR \fItime\fR\fR -.ad -.RS 18n -Select processes existing at or after \fItime\fR, given in the format -\fIhr\fR\|[\|:\fImin\fR\|[\|:\fIsec\fR\|]\|]. -.RE - -.sp -.ne 2 -.na -\fB\fB-S\fR \fItime\fR\fR -.ad -.RS 18n -Select processes starting at or after \fItime\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-u\fR \fIuser\fR\fR -.ad -.RS 18n -Show only processes belonging to \fIuser\fR. The user may be specified by a -user \fBID\fR, a login name that is then converted to a user \fBID\fR, -`\fB#\fR' (which designates only those processes executed with superuser -privileges), or `\fB?\fR' (which designates only those processes associated -with unknown user \fBID\fRs). -.RE - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/etc/group\fR\fR -.ad -.RS 22n -system group file -.RE - -.sp -.ne 2 -.na -\fB\fB/etc/passwd\fR\fR -.ad -.RS 22n -system password file -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/pacct\fIincr\fR\fR\fR -.ad -.RS 22n -active processes accounting file -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -CSI Enabled -.TE - -.SH SEE ALSO -.sp -.LP -\fBps\fR(1), \fBacct\fR(8), \fBacctcms\fR(8), \fBacctcon\fR(8), -\fBacctmerg\fR(8), \fBacctprc\fR(8), \fBacctsh\fR(8), \fBfwtmp\fR(8), -\fBrunacct\fR(8), \fBsu\fR(8), \fBacct\fR(2), \fBregcmp\fR(3C), -\fBacct.h\fR(3HEAD), \fButmp\fR(4), \fBattributes\fR(5) -.sp -.LP -\fISystem Administration Guide: Basic Administration\fR -.SH NOTES -.sp -.LP -\fBacctcom\fR reports only on processes that have terminated; use \fBps\fR(1) -for active processes.
--- a/share/man/man1/sar.1 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,682 +0,0 @@ -'\" te -.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved -.\" Copyright 1989 AT&T -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH SAR 1 "May 13, 2017" -.SH NAME -sar \- system activity reporter -.SH SYNOPSIS -.LP -.nf -\fBsar\fR [\fB-aAbcdgkmpqruvwy\fR] [\fB-o\fR \fIfilename\fR] \fIt\fR [\fIn\fR] -.fi - -.LP -.nf -\fBsar\fR [\fB-aAbcdgkmpqruvwy\fR] [\fB-e\fR \fItime\fR] [\fB-f\fR \fIfilename\fR] [\fB-i\fR \fIsec\fR] - [\fB-s\fR \fItime\fR] -.fi - -.SH DESCRIPTION -.LP -In the first instance, the \fBsar\fR utility samples cumulative activity -counters in the operating system at \fIn\fR intervals of \fIt\fR seconds, where -\fIt\fR should be \fB5\fR or greater. If \fIt\fR is specified with more than -one option, all headers are printed together and the output can be difficult to -read. (If the sampling interval is less than \fB5\fR, the activity of \fBsar\fR -itself can affect the sample.) If the \fB-o\fR option is specified, it saves -the samples in \fIfilename\fR in binary format. The default value of \fIn\fR is -\fB1\fR. -.sp -.LP -In the second instance, no sampling interval is specified. \fBsar\fR extracts -data from a previously recorded \fIfilename\fR, either the one specified by the -\fB-f\fR option or, by default, the standard system activity daily data file -\fB/var/log/sa/sa\fIdd\fR\fR for the current day \fIdd\fR. The starting and -ending times of the report can be bounded using the \fB-e\fR and \fB-s\fR -arguments with \fItime\fR specified in the form \fIhh\fR[:\fImm\fR[:\fIss\fR]]. -The \fB-i\fR option selects records at \fIsec\fR second intervals. Otherwise, -all intervals found in the data file are reported. -.SH OPTIONS -.LP -The following options modify the subsets of information reported by \fBsar\fR. -.sp -.ne 2 -.na -\fB\fB-a\fR\fR -.ad -.RS 15n -Reports use of file access system routines: iget/s, namei/s, dirblk/s -.RE - -.sp -.ne 2 -.na -\fB\fB-A\fR\fR -.ad -.RS 15n -Reports all data. Equivalent to \fB-abcdgkmpqruvwy\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-b\fR\fR -.ad -.RS 15n -Reports buffer activity: -.sp -.ne 2 -.na -\fBbread/s, bwrit/s\fR -.ad -.RS 20n -transfers per second of data between system buffers and disk or other block -devices. -.RE - -.sp -.ne 2 -.na -\fBlread/s, lwrit/s\fR -.ad -.RS 20n -accesses of system buffers. -.RE - -.sp -.ne 2 -.na -\fB%rcache, %wcache\fR -.ad -.RS 20n -cache hit ratios, that is, (1\(mibread/lread) as a percentage. -.RE - -.sp -.ne 2 -.na -\fBpread/s, pwrit/s\fR -.ad -.RS 20n -transfers using raw (physical) device mechanism. -.RE - -If run in a non-global zone and the pools facility is active, these values -reflect activity on the processors of the processor set of the pool to which -the zone is bound. -.RE - -.sp -.ne 2 -.na -\fB\fB-c\fR\fR -.ad -.RS 15n -Reports system calls: -.sp -.ne 2 -.na -\fBscall/s\fR -.ad -.sp .6 -.RS 4n -system calls of all types. -.RE - -.sp -.ne 2 -.na -\fBsread/s, swrit/s, fork/s, exec/s\fR -.ad -.sp .6 -.RS 4n -specific system calls. -.RE - -.sp -.ne 2 -.na -\fBrchar/s, wchar/s\fR -.ad -.sp .6 -.RS 4n -characters transferred by read and write system calls. No incoming or outgoing -\fBexec\fR(2) and \fBfork\fR(2) calls are reported. -.RE - -If run in a non-global zone and the pools facility is active, these values -reflect activity on the processors of the processor set of the pool to which -the zone is bound. -.RE - -.sp -.ne 2 -.na -\fB\fB-d\fR\fR -.ad -.RS 15n -Reports activity for each block device (for example, disk or tape drive) with -the exception of \fBXDC\fR disks and tape drives. When data is displayed, the -device specification \fIdsk-\fR is generally used to represent a disk drive. -The device specification used to represent a tape drive is machine dependent. -The activity data reported is: -.sp -.ne 2 -.na -\fB%busy, avque\fR -.ad -.RS 27n -portion of time device was busy servicing a transfer request, average number of -requests outstanding during that time. -.RE - -.sp -.ne 2 -.na -\fBread/s, write/s, blks/s\fR -.ad -.RS 27n -number of read/write transfers from or to device, number of bytes transferred -in 512-byte units. -.RE - -.sp -.ne 2 -.na -\fBavwait\fR -.ad -.RS 27n -average wait time in milliseconds. -.RE - -.sp -.ne 2 -.na -\fBavserv\fR -.ad -.RS 27n -average service time in milliseconds. -.RE - -For more general system statistics, use \fBiostat\fR(8), \fBsar\fR(8), or -\fBvmstat\fR(8). -.sp -See \fISystem Administration Guide: Advanced Administration\fR for naming -conventions for disks. -.RE - -.sp -.ne 2 -.na -\fB\fB-e\fR \fItime\fR\fR -.ad -.RS 15n -Selects data up to \fBtime\fR. Default is \fB18:00\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-f\fR \fIfilename\fR\fR -.ad -.RS 15n -Uses \fIfilename\fR as the data source for \fBsar\fR. Default is the current -daily data file \fB/var/log/sa/sa\fR\fIdd.\fR -.RE - -.sp -.ne 2 -.na -\fB\fB-g\fR\fR -.ad -.RS 15n -Reports paging activities: -.sp -.ne 2 -.na -\fBpgout/s\fR -.ad -.RS 12n -page-out requests per second. -.RE - -.sp -.ne 2 -.na -\fBppgout/s\fR -.ad -.RS 12n -pages paged-out per second. -.RE - -.sp -.ne 2 -.na -\fBpgfree/s\fR -.ad -.RS 12n -pages per second placed on the free list by the page stealing daemon. -.RE - -.sp -.ne 2 -.na -\fBpgscan/s\fR -.ad -.RS 12n -pages per second scanned by the page stealing daemon. -.RE - -.sp -.ne 2 -.na -\fB%ufs_ipf\fR -.ad -.RS 12n -the percentage of \fBUFS\fR inodes taken off the freelist by iget which had -reusable pages associated with them. These pages are flushed and cannot be -reclaimed by processes. Thus, this is the percentage of igets with page -flushes. -.RE - -If run in a non-global zone and the pools facility is active, these values -reflect activity on the processors of the processor set of the pool to which -the zone is bound. -.RE - -.sp -.ne 2 -.na -\fB\fB-i\fR \fIsec\fR\fR -.ad -.RS 15n -Selects data at intervals as close as possible to \fIsec\fR seconds. -.RE - -.sp -.ne 2 -.na -\fB\fB-k\fR\fR -.ad -.RS 15n -Reports kernel memory allocation (KMA) activities: -.sp -.ne 2 -.na -\fBsml_mem, alloc, fail\fR -.ad -.RS 24n -information about the memory pool reserving and allocating space for small -requests: the amount of memory in bytes \fBKMA\fR has for the small pool, the -number of bytes allocated to satisfy requests for small amounts of memory, and -the number of requests for small amounts of memory that were not satisfied -(failed). -.RE - -.sp -.ne 2 -.na -\fBlg_mem, alloc, fail\fR -.ad -.RS 24n -information for the large memory pool (analogous to the information for the -small memory pool). -.RE - -.sp -.ne 2 -.na -\fBovsz_alloc, fail\fR -.ad -.RS 24n -the amount of memory allocated for oversize requests and the number of oversize -requests which could not be satisfied (because oversized memory is allocated -dynamically, there is not a pool). -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR\fR -.ad -.RS 15n -Reports message and semaphore activities: -.sp -.ne 2 -.na -\fBmsg/s, sema/s\fR -.ad -.RS 17n -primitives per second. -.RE - -If run in a non-global zone and the pools facility is active, these values -reflect activity on the processors of the processor set of the pool to which -the zone is bound. -.RE - -.sp -.ne 2 -.na -\fB\fB-o\fR \fIfilename\fR\fR -.ad -.RS 15n -Saves samples in file, \fIfilename\fR, in binary format. -.RE - -.sp -.ne 2 -.na -\fB\fB-p\fR\fR -.ad -.RS 15n -Reports paging activities: -.sp -.ne 2 -.na -\fBatch/s\fR -.ad -.RS 11n -page faults per second that are satisfied by reclaiming a page currently in -memory (attaches per second). -.RE - -.sp -.ne 2 -.na -\fBpgin/s\fR -.ad -.RS 11n -page-in requests per second. -.RE - -.sp -.ne 2 -.na -\fBppgin/s\fR -.ad -.RS 11n -pages paged-in per second. -.RE - -.sp -.ne 2 -.na -\fBpflt/s\fR -.ad -.RS 11n -page faults from protection errors per second (illegal access to page) or -"copy-on-writes". -.RE - -.sp -.ne 2 -.na -\fBvflt/s\fR -.ad -.RS 11n -address translation page faults per second (valid page not in memory). -.RE - -.sp -.ne 2 -.na -\fBslock/s\fR -.ad -.RS 11n -faults per second caused by software lock requests requiring physical -\fBI/O\fR. -.RE - -If run in a non-global zone and the pools facility is active, these values -reflect activity on the processors of the processor set of the pool to which -the zone is bound. -.RE - -.sp -.ne 2 -.na -\fB\fB-q\fR\fR -.ad -.RS 15n -Reports average queue length while occupied, and percent of time occupied: -.sp -.ne 2 -.na -\fBrunq-sz, %runocc\fR -.ad -.RS 20n -Run queue of kernel threads in memory and runnable -.RE - -.sp -.ne 2 -.na -\fBswpq-sz, %swpocc\fR -.ad -.RS 20n -Swap queue of processes -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR\fR -.ad -.RS 15n -Reports unused memory pages and disk blocks: -.sp -.ne 2 -.na -\fBfreemem\fR -.ad -.RS 12n -average pages available to user processes. -.RE - -.sp -.ne 2 -.na -\fBfreeswap\fR -.ad -.RS 12n -disk blocks available for page swapping. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR \fItime\fR\fR -.ad -.RS 15n -Selects data later than \fBtime\fR in the form \fIhh\fR[:\fImm\fR]. Default is -\fB08:00\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-u\fR\fR -.ad -.RS 15n -Reports \fBCPU\fR utilization (the default): -.sp -.ne 2 -.na -\fB%usr, %sys, %wio, %idle\fR -.ad -.RS 27n -portion of time running in user mode, running in system mode, idle with some -process waiting for block \fBI/O\fR, and otherwise idle. -.RE - -If run in a non-global zone and the pools facility is active, these values -reflect activity on the processors of the processor set of the pool to which -the zone is bound. -.RE - -.sp -.ne 2 -.na -\fB\fB-v\fR\fR -.ad -.RS 15n -Reports status of process, i-node, file tables: -.sp -.ne 2 -.na -\fBproc-sz, inod-sz, file-sz, lock-sz\fR -.ad -.sp .6 -.RS 4n -entries/size for each table, evaluated once at sampling point. -.RE - -.sp -.ne 2 -.na -\fBov\fR -.ad -.sp .6 -.RS 4n -overflows that occur between sampling points for each table. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-w\fR\fR -.ad -.RS 15n -Reports system swapping and switching activity: -.sp -.ne 2 -.na -\fBswpin/s, swpot/s, bswin/s, bswot/s\fR -.ad -.sp .6 -.RS 4n -number of transfers and number of 512-byte units transferred for swapins and -swapouts (including initial loading of some programs). -.RE - -.sp -.ne 2 -.na -\fBpswch/s\fR -.ad -.sp .6 -.RS 4n -process switches. -.RE - -If run in a non-global zone and the pools facility is active, these values -reflect activity on the processors of the processor set of the pool to which -the zone is bound. -.RE - -.sp -.ne 2 -.na -\fB\fB-y\fR\fR -.ad -.RS 15n -Reports TTY device activity: -.sp -.ne 2 -.na -\fBrawch/s, canch/s, outch/s\fR -.ad -.RS 29n -input character rate, input character rate processed by canon, output character -rate. -.RE - -.sp -.ne 2 -.na -\fBrcvin/s, xmtin/s, mdmin/s\fR -.ad -.RS 29n -receive, transmit and modem interrupt rates. -.RE - -If run in a non-global zone and the pools facility is active, these values -reflect activity on the processors of the processor set of the pool to which -the zone is bound. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRViewing System Activity -.sp -.LP -The following example displays today's \fBCPU\fR activity so far: - -.sp -.in +2 -.nf -example% sar -.fi -.in -2 -.sp - -.LP -\fBExample 2 \fRWatching System Activity Evolve -.sp -.LP -To watch \fBCPU\fR activity evolve for 10 minutes and save data: - -.sp -.in +2 -.nf -example% sar -o temp 60 10 -.fi -.in -2 -.sp - -.LP -\fBExample 3 \fRReviewing Disk and Tape Activity -.sp -.LP -To later review disk and tape activity from that period: - -.sp -.in +2 -.nf -example% sar -d -f temp -.fi -.in -2 -.sp - -.SH FILES -.ne 2 -.na -\fB\fB/var/log/sa/sa\fIdd\fR\fR\fR -.ad -.RS 20n -daily data file, where \fIdd\fR are digits representing the day of the month -.RE - -.SH SEE ALSO -.LP -\fBiostat\fR(8), \fBsar\fR(8), \fBvmstat\fR(8), \fBexec\fR(2), -\fBfork\fR(2), \fBattributes\fR(5) -.sp -.LP -\fISystem Administration Guide: Advanced Administration\fR -.SH NOTES -.LP -The sum of CPU utilization might vary slightly from 100 because of rounding -errors in the production of a percentage figure.
--- a/share/man/man1/timex.1 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 1992, Sun Microsystems, Inc. All Rights Reserved -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH TIMEX 1 "Sep 14, 1992" -.SH NAME -timex \- time a command; report process data and system activity -.SH SYNOPSIS -.LP -.nf -\fBtimex\fR [\fB-o\fR] [\fB-p\fR [\fB-fhkmrt\fR]] [\fB-s\fR] \fIcommand\fR -.fi - -.SH DESCRIPTION -.sp -.LP -The given \fBcommand\fR is executed; the elapsed time, user time and system -time spent in execution are reported in seconds. Optionally, process accounting -data for the \fBcommand\fR and all its children can be listed or summarized, -and total system activity during the execution interval can be reported. -.sp -.LP -The output of \fBtimex\fR is written on standard error. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-o\fR\fR -.ad -.RS 6n -Report the total number of blocks read or written and total characters -transferred by \fBcommand\fR and all its children. This option works only if -the process accounting software is installed. -.RE - -.sp -.ne 2 -.na -\fB\fB-p\fR\fR -.ad -.RS 6n -List process accounting records for \fBcommand\fR and all its children. This -option works only if the process accounting software is installed. Suboptions -\fBf\fR, \fBh\fR, \fBk\fR, \fBm\fR, \fBr\fR, and \fBt\fR modify the data items -reported. The options are as follows: -.sp -.ne 2 -.na -\fB\fB-f\fR\fR -.ad -.RS 6n -Print the \fBfork\fR(2)/ \fBexec\fR(2) flag and system exit status columns in -the output. -.RE - -.sp -.ne 2 -.na -\fB\fB-h\fR\fR -.ad -.RS 6n -Instead of mean memory size, show the fraction of total available CPU time -consumed by the process during its execution. This ``hog factor'' is computed -as (total CPU time)/(elapsed time). -.RE - -.sp -.ne 2 -.na -\fB\fB-k\fR\fR -.ad -.RS 6n -Instead of memory size, show total kcore-minutes. -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR\fR -.ad -.RS 6n -Show mean core size (the default). -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR\fR -.ad -.RS 6n -Show CPU factor (user time/(system-time + user-time)). -.RE - -.sp -.ne 2 -.na -\fB\fB-t\fR\fR -.ad -.RS 6n -Show separate system and user CPU times. The number of blocks read or written -and the number of characters transferred are always reported. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR\fR -.ad -.RS 6n -Report total system activity (not just that due to \fBcommand\fR) that -occurred during the execution interval of \fBcommand\fR. All the data items -listed in \fBsar\fR(1) are reported. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRExamples of \fBtimex\fR. -.sp -.LP -A simple example: - -.sp -.in +2 -.nf -\fBexample% timex \fR\fB-ops\fR\fB sleep 60\fR -.fi -.in -2 -.sp - -.sp -.LP -A terminal session of arbitrary complexity can be measured by timing a -sub-shell: - -.sp -.in +2 -.nf -\fBexample% timex \fR\fB-opskmt\fR\fB sh\fR - \fIsession commands\fR -\fBEOT\fR -.fi -.in -2 -.sp - -.SH SEE ALSO -.sp -.LP -\fBsar\fR(1), \fBtime\fR(1), \fBexec\fR(2), \fBfork\fR(2), \fBtimes\fR(2), -\fBattributes\fR(5) -.SH NOTES -.sp -.LP -Process records associated with \fBcommand\fR are selected from the accounting -file \fB/var/log/pacct\fR by inference, since process genealogy is not -available. Background processes having the same user ID, terminal ID, and -execution time window will be spuriously included.
--- a/share/man/man4/Makefile Mon May 20 17:16:39 2019 -0400 +++ b/share/man/man4/Makefile Mon May 20 19:46:49 2019 -0400 @@ -42,7 +42,6 @@ group.4 \ gsscred.conf.4 \ hba.conf.4 \ - holidays.4 \ hosts.4 \ hosts.equiv.4 \ hosts_access.4 \
--- a/share/man/man4/holidays.4 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -'\" te -.\" Copyright (c) 2008, Sun Microsystems, Inc. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH HOLIDAYS 4 "Aug 18, 2008" -.SH NAME -holidays \- prime/nonprime table for the accounting system -.SH SYNOPSIS -.LP -.nf -\fB/etc/acct/holidays\fR -.fi - -.SH DESCRIPTION -.sp -.LP -The \fB/etc/acct/holidays\fR file specifies prime time hours and holidays. -Holidays and weekends are considered non-prime time hours. -.sp -.LP -\fB/etc/acct/holidays\fR is used by the accounting system. -.sp -.LP -All lines beginning with an \fB*\fR are comments. -.sp -.LP -The \fB/etc/acct/holidays\fR file consists of two sections. The first -non-comment line defines the current year and the start time of prime and -non-prime time hours, in the form of: -.sp -.in +2 -.nf -\fIcurrent_year\fR \fIprime_start\fR \fInon_prime_start\fR -.fi -.in -2 - -.sp -.LP -Specify \fIprime_start\fR and \fInon_prime_start\fR times in the range of -\fB0000\fR to \fB2400\fR. -.sp -.LP -The remaining non-comment lines define the holidays in the form of: -.sp -.in +2 -.nf -\fImonth/day\fR \fIcompany_holiday\fR -.fi -.in -2 - -.sp -.LP -Of these two fields, only the \fImonth/day\fR is actually used by the -accounting system programs. -.sp -.LP -The \fB/etc/acct/holidays\fR file must be updated every year. -.SH EXAMPLES -.LP -\fBExample 1 \fRAn Example of the \fB/etc/acct/holidays\fR File -.sp -.LP -The following is an example of the \fB/etc/acct/holidays\fR file: - -.sp -.in +2 -.nf -* Prime/Nonprime Table for the accounting system -* -* Curr Prime Non-Prime -* Year Start Start -* - 1991 0830 1800 -* -* only the first column (month/day) is significant. -* -* month/day Company Holiday -* - 1/1 New Years Day - 5/30 Memorial Day - 7/4 Indep. Day - 9/5 Labor Day - 11/24 Thanksgiving Day - 11/25 day after Thanksgiving - 12/25 Christmas - 12/26 day after Christmas -.fi -.in -2 - -.SH SEE ALSO -.sp -.LP -\fBacct\fR(8)
--- a/share/man/man8/Makefile Mon May 20 17:16:39 2019 -0400 +++ b/share/man/man8/Makefile Mon May 20 19:46:49 2019 -0400 @@ -5,13 +5,7 @@ MAN = 6to4relay.8 \ Intro.8 \ - acct.8 \ acctadm.8 \ - acctcms.8 \ - acctcon.8 \ - acctmerg.8 \ - acctprc.8 \ - acctsh.8 \ add_drv.8 \ arcstat.8 \ arp.8 \ @@ -98,7 +92,6 @@ fstyp.8 \ fuser.8 \ fwflash.8 \ - fwtmp.8 \ getdev.8 \ getdevpolicy.8 \ getdgrp.8 \ @@ -316,12 +309,10 @@ rsh.8 \ rtc.8 \ rtquery.8 \ - runacct.8 \ rwall.8 \ sac.8 \ sacadm.8 \ saf.8 \ - sar.8 \ sasinfo.8 \ savecore.8 \ sbdadm.8 \
--- a/share/man/man8/acct.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,219 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 2000, Sun Microsystems, Inc. All Rights Reserved -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH ACCT 8 "Feb 22, 1999" -.SH NAME -acct, acctdisk, acctdusg, accton, acctwtmp, closewtmp, utmp2wtmp \- overview of -accounting and miscellaneous accounting commands -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/acct/acctdisk\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/acctdusg\fR [\fB-u\fR \fIfilename\fR] [\fB-p\fR \fIfilename\fR] -.fi - -.LP -.nf -\fB/usr/lib/acct/accton\fR [\fIfilename\fR] -.fi - -.LP -.nf -\fB/usr/lib/acct/acctwtmp\fR \fIreason\fR \fIfilename\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/closewtmp\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/utmp2wtmp\fR -.fi - -.SH DESCRIPTION -.sp -.LP -Accounting software is structured as a set of tools (consisting of both C -programs and shell procedures) that can be used to build accounting systems. -\fBacctsh\fR(8) describes the set of shell procedures built on top of the C -programs. -.sp -.LP -Connect time accounting is handled by various programs that write records into -\fB/var/log/wtmpx\fR, as described in \fButmpx\fR(4). The programs described in -\fBacctcon\fR(8) convert this file into session and charging records, which -are then summarized by \fBacctmerg\fR(8). -.sp -.LP -Process accounting is performed by the system kernel. Upon termination of a -process, one record per process is written to a file (normally -\fB/var/log/pacct\fR). The programs in \fBacctprc\fR(8) summarize this data -for charging purposes; \fBacctcms\fR(8) is used to summarize command usage. -Current process data may be examined using \fBacctcom\fR(1). -.sp -.LP -Process accounting records and connect time accounting records (or any -accounting records in the \fBtacct\fR format described in \fBacct.h\fR(3HEAD)) -can be merged and summarized into total accounting records by \fBacctmerg\fR -(see \fBtacct\fR format in \fBacct.h\fR(3HEAD)). \fBprtacct\fR (see -\fBacctsh\fR(8)) is used to format any or all accounting records. -.sp -.LP -\fBacctdisk\fR reads lines that contain user \fBID\fR, login name, and number -of disk blocks and converts them to total accounting records that can be merged -with other accounting records. \fBacctdisk\fR returns an error if the input -file is corrupt or improperly formatted. -.sp -.LP -\fBacctdusg\fR reads its standard input (usually from \fBfind\fR \fB/\fR -\fB-\fR\fBprint\fR) and computes disk resource consumption (including indirect -blocks) by login. -.sp -.LP -\fBaccton\fR without arguments turns process accounting off. If \fIfilename\fR -is given, it must be the name of an existing file, to which the kernel appends -process accounting records (see \fBacct\fR(2) and \fBacct.h\fR(3HEAD)). -.sp -.LP -\fBacctwtmp\fR writes a \fButmpx\fR(4) record to \fIfilename\fR. The record -contains the current time and a string of characters that describe the -\fIreason\fR. A record type of \fBACCOUNTING\fR is assigned (see -\fButmpx\fR(4)) \fIreason\fR must be a string of 11 or fewer characters, -numbers, \fB$\fR, or spaces. For example, the following are suggestions for use -in reboot and shutdown procedures, respectively: -.sp -.in +2 -.nf -acctwtmp "acctg on" /var/log/wtmpx -acctwtmp "acctg off" /var/log/wtmpx -.fi -.in -2 - -.sp -.LP -For each user currently logged on, \fBclosewtmp\fR puts a false -\fBDEAD_PROCESS\fR record in the \fB/var/log/wtmpx\fR file. \fBrunacct\fR (see -\fBrunacct\fR(8)) uses this false \fBDEAD_PROCESS\fR record so that the -connect accounting procedures can track the time used by users logged on before -\fBrunacct\fR was invoked. -.sp -.LP -For each user currently logged on, \fBrunacct\fR uses \fButmp2wtmp\fR to create -an entry in the file \fB/var/log/wtmpx\fR, created by \fBrunacct\fR. Entries in -\fB/var/log/wtmpx\fR enable subsequent invocations of \fBrunacct\fR to account -for connect times of users currently logged in. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-u\fR \fIfilename\fR\fR -.ad -.RS 15n -Places in \fIfilename\fR records consisting of those filenames for which -\fBacctdusg\fR charges no one (a potential source for finding users trying to -avoid disk charges). -.RE - -.sp -.ne 2 -.na -\fB\fB-p\fR \fIfilename\fR\fR -.ad -.RS 15n -Specifies a password file, \fIfilename\fR. This option is not needed if the -password file is \fB/etc/passwd\fR. -.RE - -.SH ENVIRONMENT VARIABLES -.sp -.LP -If any of the \fBLC_*\fR variables (\fBLC_TYPE\fR, \fBLC_MESSAGES\fR, -\fBLC_TIME\fR, \fBLC_COLLATE\fR, \fBLC_NUMERIC\fR, and \fBLC_MONETARY\fR) (see -\fBenviron\fR(5)) are not set in the environment, the operational behavior of -\fBacct\fR for each corresponding locale category is determined by the value of -the \fBLANG\fR environment variable. If \fBLC_ALL\fR is set, its contents are -used to override both the \fBLANG\fR and the other \fBLC_*\fR variables. If -none of the above variables are set in the environment, the "C" (U.S. style) -locale determines how \fBacct\fR behaves. -.sp -.ne 2 -.na -\fB\fBLC_CTYPE\fR\fR -.ad -.RS 12n -Determines how \fBacct\fR handles characters. When \fBLC_CTYPE\fR is set to a -valid value, \fBacct\fR can display and handle text and filenames containing -valid characters for that locale. \fBacct\fR can display and handle Extended -Unix Code (EUC) characters where any character can be 1, 2, or 3 bytes wide. -\fBacct\fR can also handle EUC characters of 1, 2, or more column widths. In -the "C" locale, only characters from ISO 8859-1 are valid. -.RE - -.sp -.ne 2 -.na -\fB\fBLC_TIME\fR\fR -.ad -.RS 12n -Determines how \fBacct\fR handles date and time formats. In the "C" locale, -date and time handling follows the U.S. rules. -.RE - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/etc/passwd\fR\fR -.ad -.RS 18n -Used for login name to user \fBID\fR conversions. -.RE - -.sp -.ne 2 -.na -\fB\fB/usr/lib/acct\fR\fR -.ad -.RS 18n -Holds all accounting commands listed in sub-class 8 of this manual. -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/pacct\fR\fR -.ad -.RS 18n -Current process accounting file. -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/wtmpx\fR\fR -.ad -.RS 18n -History of user access and administration information.. -.RE - -.SH SEE ALSO -.sp -.LP -\fBacctcom\fR(1), \fBacctcms\fR(8), \fBacctcon\fR(8), \fBacctmerg\fR(8), -\fBacctprc\fR(8), \fBacctsh\fR(8), \fBfwtmp\fR(8), \fBrunacct\fR(8), -\fBacct\fR(2), \fBacct.h\fR(3HEAD), \fBpasswd\fR(4), \fButmpx\fR(4), -\fBattributes\fR(5), \fBenviron\fR(5) -.sp -.LP -\fI\fR
--- a/share/man/man8/acctcms.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 1999, Sun Microsystems, Inc. All Rights Reserved -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH ACCTCMS 8 "Feb 22, 1999" -.SH NAME -acctcms \- command summary from process accounting records -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/acct/acctcms\fR [\fB-a\fR [\fB-o\fR] [\fB-p\fR]] [\fB-c\fR] [\fB-j\fR] [\fB-n\fR] [\fB-s\fR] - [\fB-t\fR] \fIfilename\fR... -.fi - -.SH DESCRIPTION -.sp -.LP -\fBacctcms\fR reads one or more \fIfilename\fRs, normally in the form described -in \fBacct.h\fR(3HEAD). It adds all records for processes that executed -identically named commands, sorts them, and writes them to the standard output, -normally using an internal summary format. -.SH OPTIONS -.sp -.ne 2 -.na -\fB\fB-a\fR\fR -.ad -.RS 6n -Print output in \fBASCII\fR rather than in the internal summary format. The -output includes command name, number of times executed, total kcore-minutes, -total \fBCPU\fR minutes, total real minutes, mean size (in K), mean \fBCPU\fR -minutes per invocation, "hog factor," characters transferred, and blocks read -and written, as in \fBacctcom\fR(1). Output is normally sorted by total -kcore-minutes. -.sp -Use the following options only with the \fB-a\fR option: -.sp -.ne 2 -.na -\fB\fB-o\fR\fR -.ad -.RS 6n -Output a (non-prime) offshift-time-only command summary. -.RE - -.sp -.ne 2 -.na -\fB\fB-p\fR\fR -.ad -.RS 6n -Output a prime-time-only command summary. -.RE - -When \fB-o\fR and \fB-p\fR are used together, a combination prime-time and -non-prime-time report is produced. All the output summaries are total usage -except number of times executed, CPU minutes, and real minutes, which are split -into prime and non-prime. -.RE - -.sp -.ne 2 -.na -\fB\fB-c\fR\fR -.ad -.RS 6n -Sort by total \fBCPU\fR time, rather than total kcore-minutes. -.RE - -.sp -.ne 2 -.na -\fB\fB-j\fR\fR -.ad -.RS 6n -Combine all commands invoked only once under "***other". -.RE - -.sp -.ne 2 -.na -\fB\fB-n\fR\fR -.ad -.RS 6n -Sort by number of command invocations. -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR\fR -.ad -.RS 6n -Any file names encountered hereafter are already in internal summary format. -.RE - -.sp -.ne 2 -.na -\fB\fB-t\fR\fR -.ad -.RS 6n -Process all records as total accounting records. The default internal summary -format splits each field into prime and non-prime-time parts. This option -combines the prime and non-prime time parts into a single field that is the -total of both, and provides upward compatibility with old style \fBacctcms\fR -internal summary format records. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRUsing the \fBacctcms\fR command. -.sp -.LP -A typical sequence for performing daily command accounting and for maintaining -a running total is: - -.sp -.in +2 -.nf -example%\fB acctcms filename ... > today\fR -example% \fBcp total previoustotal\fR -example% \fBacctcms \fR\fB-s\fR\fB today previoustotal > total\fR -example% \fBacctcms \fR\fB-a\fR\fB \fR\fB-s\fR\fB today\fR -.fi -.in -2 -.sp - -.SH SEE ALSO -.sp -.LP -\fBacctcom\fR(1), \fBacct\fR(8), \fBacctcon\fR(8), \fBacctmerg\fR(8), -\fBacctprc\fR(8), \fBacctsh\fR(8), \fBfwtmp\fR(8), \fBrunacct\fR(8), -\fBacct\fR(2), \fBacct.h\fR(3HEAD), \fButmpx\fR(4), \fBattributes\fR(5) -.SH NOTES -.sp -.LP -Unpredictable output results if \fB-t\fR is used on new style internal summary -format files, or if it is not used with old style internal summary format -files.
--- a/share/man/man8/acctcon.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,174 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH ACCTCON 8 "Feb 22, 1999" -.SH NAME -acctcon, acctcon1, acctcon2 \- connect-time accounting -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/acct/acctcon\fR [\fB-l\fR \fIlineuse\fR] [\fB-o\fR \fIreboot\fR] -.fi - -.LP -.nf -\fB/usr/lib/acct/acctcon1\fR [\fB-p\fR] [\fB-t\fR] [\fB-l\fR \fIlineuse\fR] [\fB-o\fR \fIreboot\fR] -.fi - -.LP -.nf -\fB/usr/lib/acct/acctcon2\fR -.fi - -.SH DESCRIPTION -.sp -.LP -\fBacctcon\fR converts a sequence of login/logoff records to total accounting -records (see the \fBtacct\fR format in \fBacct.h\fR(3HEAD)). The login/logoff -records are read from standard input. The file \fB/var/log/wtmpx\fR is usually -the source of the login/logoff records; however, because it might contain -corrupted records or system date changes, it should first be fixed using -\fBwtmpfix\fR. The fixed version of file \fB/var/log/wtmpx\fR can then be -redirected to \fBacctcon\fR. The \fBtacct\fR records are written to standard -output. -.sp -.LP -\fBacctcon\fR is a combination of the programs \fBacctcon1\fR and -\fBacctcon2\fR. \fBacctcon1\fR converts login/logoff records, taken from the -fixed \fB/var/log/wtmpx\fR file, to ASCII output. \fBacctcon2\fR reads the -ASCII records produced by \fBacctcon1\fR and converts them to \fBtacct\fR -records. \fBacctcon1\fR can be used with the \fB-l\fR and \fB-o\fR options, -described below, as well as with the \fB-p\fR and \fB-t\fR options. -.SH OPTIONS -.sp -.ne 2 -.na -\fB\fB-p\fR\fR -.ad -.RS 14n -Print input only, showing line name, login name, and time (in both numeric and -date/time formats). -.RE - -.sp -.ne 2 -.na -\fB\fB-t\fR\fR -.ad -.RS 14n -\fBacctcon1\fR maintains a list of lines on which users are logged in. When it -reaches the end of its input, it emits a session record for each line that -still appears to be active. It normally assumes that its input is a current -file, so that it uses the current time as the ending time for each session -still in progress. The \fB-t\fR flag causes it to use, instead, the last time -found in its input, thus assuring reasonable and repeatable numbers for -non-current files. -.RE - -.sp -.ne 2 -.na -\fB\fB-l\fR \fIlineuse\fR\fR -.ad -.RS 14n -\fIlineuse\fR is created to contain a summary of line usage showing line name, -number of minutes used, percentage of total elapsed time used, number of -sessions charged, number of logins, and number of logoffs. This file helps -track line usage, identify bad lines, and find software and hardware oddities. -Hangup, termination of \fBlogin\fR(1) and termination of the login shell each -generate logoff records, so that the number of logoffs is often three to four -times the number of sessions. See \fB init\fR(8) and \fButmpx\fR(4). -.RE - -.sp -.ne 2 -.na -\fB\fB-o\fR \fIreboot\fR\fR -.ad -.RS 14n -\fBreboot\fR is filled with an overall record for the accounting period, giving -starting time, ending time, number of reboots, and number of date changes. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRUsing the \fBacctcon\fR command. -.sp -.LP -The \fBacctcon\fR command is typically used as follows: - -.sp -.in +2 -.nf -example% acctcon \fB-l\fR lineuse \fB-o\fR reboots < tmpwtmp > ctacct -.fi -.in -2 -.sp - -.sp -.LP -The \fBacctcon1\fR and \fBacctcon2\fR commands are typically used as follows: - -.sp -.in +2 -.nf -example% acctcon1 \fB-l\fR lineuse \fB-o\fR reboots < tmpwtmp | sort +1n +2 > ctmp -example% acctcon2 < ctmp > ctacct -.fi -.in -2 -.sp - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/var/log/wtmpx\fR\fR -.ad -.RS 18n -History of user access and administration information -.RE - -.SH SEE ALSO -.sp -.LP -\fBacctcom\fR(1), \fBlogin\fR(1), \fBacct\fR(8), \fBacctcms\fR(8), -\fBacctmerg\fR(8), \fBacctprc\fR(8), \fBacctsh\fR(8), \fBfwtmp\fR(8), -\fBinit\fR(8), \fBrunacct\fR(8), \fBacct\fR(2), \fBacct.h\fR(3HEAD), -\fButmpx\fR(4), \fBattributes\fR(5) -.sp -.LP -\fI\fR -.SH NOTES -.sp -.LP -The line usage report is confused by date changes. Use \fBwtmpfix\fR (see -\fBfwtmp\fR(8)), with the \fB/var/log/wtmpx\fR file as an argument, to correct -this situation. -.sp -.LP -During a single invocation of any given command, the \fBacctcon\fR, -\fBacctcon1\fR, and \fBacctcon2\fR commands can process a maximum of: -.RS +4 -.TP -.ie t \(bu -.el o -6000 distinct session -.RE -.RS +4 -.TP -.ie t \(bu -.el o -1000 distinct terminal lines -.RE -.RS +4 -.TP -.ie t \(bu -.el o -2000 distinct login names -.RE -.sp -.LP -If at some point the actual number of any one of these items exceeds the -maximum, the command will not succeed.
--- a/share/man/man8/acctmerg.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH ACCTMERG 8 "Feb 22, 1999" -.SH NAME -acctmerg \- merge or add total accounting files -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/acct/acctmerg\fR [\fB-a\fR] [\fB-i\fR] [\fB-p\fR] [\fB-t\fR] [\fB-u\fR] [\fB-v\fR] - [\fIfilename\fR] ... -.fi - -.SH DESCRIPTION -.sp -.LP -\fBacctmerg\fR reads its standard input and up to nine additional files, all in -the \fBtacct\fR format (see \fBacct.h\fR(3HEAD)) or an \fBASCII\fR version -thereof. It merges these inputs by adding records whose keys (normally user -\fBID\fR and name) are identical, and expects the inputs to be sorted on those -keys. -.SH OPTIONS -.sp -.ne 2 -.na -\fB\fB-a\fR\fR -.ad -.RS 6n -Produce output in \fBASCII\fR version of \fBtacct\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-i\fR\fR -.ad -.RS 6n -Produce input in \fBASCII\fR version of \fBtacct\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-p\fR\fR -.ad -.RS 6n -Print input with no processing. -.RE - -.sp -.ne 2 -.na -\fB\fB-t\fR\fR -.ad -.RS 6n -Produce a single record that totals all input. -.RE - -.sp -.ne 2 -.na -\fB\fB-u\fR\fR -.ad -.RS 6n -Summarize by user \fBID,\fR rather than by user \fBID\fR and name. -.RE - -.sp -.ne 2 -.na -\fB\fB-v\fR\fR -.ad -.RS 6n -Produce output in verbose \fBASCII\fR format, with more precise notation for -floating-point numbers. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRUsing the \fBacctmerg\fR command. -.sp -.LP -The following sequence is useful for making "repairs" to any file kept in this -format: - -.sp -.in +2 -.nf -example% acctmerg \|\|\fB-v\fR \|<\fIfilename1\fR\fB\|>\fR\fIfilename2\fR -.fi -.in -2 -.sp - -.sp -.LP -Edit \fIfilename2\fR as you want: - -.sp -.in +2 -.nf -\fBexample% acctmerg \|\|\fR\fB-i\fR\fB \|\fR\fI<filename2\fR\fB\|>\fR\fIfilename1\fR -.fi -.in -2 -.sp - -.SH SEE ALSO -.sp -.LP -\fBacctcom\fR(1), \fBacct\fR(8), \fBacctcms\fR(8), \fBacctcon\fR(8), -\fBacctprc\fR(8), \fBacctsh\fR(8), \fBfwtmp\fR(8), \fBrunacct\fR(8), -\fBacct\fR(2), \fBacct.h\fR(3HEAD), \fButmpx\fR(4), \fBattributes\fR(5) -.sp -.LP -\fI\fR
--- a/share/man/man8/acctprc.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -'\" te -.\" Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved. -.\" Copyright 1989 AT&T -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH ACCTPRC 8 "Jul 15, 2004" -.SH NAME -acctprc, acctprc1, acctprc2 \- process accounting -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/acct/acctprc\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/acctprc1\fR [\fIctmp\fR] -.fi - -.LP -.nf -\fB/usr/lib/acct/acctprc2\fR -.fi - -.SH DESCRIPTION -.sp -.LP -\fBacctprc\fR reads the standard input and converts it to total accounting -records (see the \fBtacct\fR record in \fBacct.h\fR(3HEAD)). \fBacctprc\fR -divides CPU time into prime time and non-prime time and determines mean memory -size (in memory segment units). \fBacctprc\fR then summarizes the \fBtacct\fR -records, according to user IDs, and adds login names corresponding to the user -IDs. The summarized records are then written to the standard output. -\fBacctprc1\fR reads input in the form described by \fBacct.h\fR(3HEAD), adds -login names corresponding to user \fBIDs,\fR then writes for each process an -\fBASCII\fR line giving user \fBID,\fR login name, prime \fBCPU\fR time (tics), -non-prime \fBCPU\fR time (tics), and mean memory size (in memory segment -units). If \fIctmp\fR is given, it should contain a list of login sessions -sorted by user \fBID\fR and login name. If this file is not supplied, it -obtains login names from the password file, just as \fBacctprc\fR does. The -information in \fIctmp\fR helps it distinguish between different login names -that share the same user \fBID.\fR -.sp -.LP -From the standard input, \fBacctprc2\fR reads records in the form written by -\fBacctprc1\fR, summarizes them according to user \fBID\fR and name, then -writes the sorted summaries to the standard output as total accounting records. -.SH EXAMPLES -.LP -\fBExample 1 \fRExamples of \fBacctprc\fR. -.sp -.LP -The \fBacctprc\fR command is typically used as shown below: - -.sp -.in +2 -.nf -example% acctprc \|< /var/log/pacct \|> ptacct -.fi -.in -2 -.sp - -.sp -.LP -The \fBacctprc1\fR and \fBacctprc2s\fR commands are typically used as shown -below: - -.sp -.in +2 -.nf -example% acctprc1 \|ctmp \|</var/log/pacct -example% acctprc2 > ptacct -.fi -.in -2 -.sp - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/etc/passwd\fR\fR -.ad -.RS 15n -system password file -.RE - -.SH SEE ALSO -.sp -.LP -\fBacctcom\fR(1), \fBacct\fR(8), \fBacctcms\fR(8), \fBacctcon\fR(8), -\fBacctmerg\fR(8), \fBacctsh\fR(8), \fBcron\fR(8), \fBfwtmp\fR(8), -\fBrunacct\fR(8), \fBacct\fR(2), \fBacct.h\fR(3HEAD), \fButmpx\fR(4), -\fBattributes\fR(5) -.SH NOTES -.sp -.LP -Although it is possible for \fBacctprc1\fR to distinguish among login names -that share user \fBIDs\fR for commands run from a command line, it is difficult -for \fBacctprc1\fR to make this distinction for commands invoked in other ways. -A command run from \fBcron\fR(8) is an example of where \fBacctprc1\fR might -have difficulty. A more precise conversion can be done using the \fBacctwtmp\fR -program in \fBacct\fR(8). \fBacctprc\fR does not distinguish between users -with identical user IDs. -.sp -.LP -A memory segment of the mean memory size is a unit of measure for the number of -bytes in a logical memory segment on a particular processor. -.sp -.LP -During a single invocation of any given command, the \fBacctprc\fR, -\fBacctprc1\fR, and \fBacctprc2\fR commands can process a maximum of -.RS +4 -.TP -.ie t \(bu -.el o -6000 distinct sessions -.RE -.RS +4 -.TP -.ie t \(bu -.el o -1000 distinct terminal lines -.RE -.RS +4 -.TP -.ie t \(bu -.el o -2000 distinct login names -.RE -.sp -.LP -If at some point the actual number of any one of these items exceeds the -maximum, the command will not succeed.
--- a/share/man/man8/acctsh.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,323 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 2002 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH ACCTSH 8 "Mar 15, 2002" -.SH NAME -acctsh, chargefee, ckpacct, dodisk, lastlogin, monacct, nulladm, prctmp, -prdaily, prtacct, shutacct, startup, turnacct \- shell procedures for -accounting -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/acct/chargefee\fR \fIlogin-name\fR \fInumber\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/ckpacct\fR [\fIblocks\fR] -.fi - -.LP -.nf -\fB/usr/lib/acct/dodisk\fR [\fB-o\fR] [\fIfilename\fR]... -.fi - -.LP -.nf -\fB/usr/lib/acct/lastlogin\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/monacct\fR \fInumber\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/nulladm\fR \fIfilename\fR... -.fi - -.LP -.nf -\fB/usr/lib/acct/prctmp\fR \fIfilename\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/prdaily\fR [\fB-c\fR] [\fB-l\fR] [\fImmdd\fR] -.fi - -.LP -.nf -\fB/usr/lib/acct/prtacct\fR \fIfilename\fR ['' \fIheading\fR ''] -.fi - -.LP -.nf -\fB/usr/lib/acct/shutacct\fR ['' \fIreason\fR ''] -.fi - -.LP -.nf -\fB/usr/lib/acct/startup\fR -.fi - -.LP -.nf -\fB/usr/lib/acct/turnacct\fR on | off | switch -.fi - -.SH DESCRIPTION -.SS "chargefee Command" -.sp -.LP -\fBchargefee\fR can be invoked to charge a \fInumber\fR of units to -\fIlogin-name\fR. A record is written to \fB/var/log/fee\fR, to be merged with -other accounting records by \fBrunacct\fR(8). -.SS "ckpacct Command" -.sp -.LP -\fBckpacct\fR should be initiated using \fBcron\fR(8) to periodically check -the size of \fB/var/log/pacct\fR. If the size exceeds \fIblocks\fR, \fB500\fR -by default, \fBturnacct\fR will be invoked with argument \fBswitch\fR. To avoid -a conflict with \fBturnacct switch\fR execution in \fBrunacct\fR, do not run -\fBckpacct\fR and \fBrunacct\fR simultaneously. If the number of free disk -blocks in the \fB/var\fR file system falls below \fB500\fR, \fBckpacct\fR will -automatically turn off the collection of process accounting records via the -\fBoff\fR argument to \fBturnacct\fR. When at least \fB500\fR blocks are -restored, the accounting will be activated again on the next invocation of -\fBckpacct\fR. This feature is sensitive to the frequency at which -\fBckpacct\fR is executed, usually by the \fBcron\fR(8) command. -.SS "dodisk Command" -.sp -.LP -\fBdodisk\fR should be invoked by \fBcron\fR(8) to perform the disk accounting -functions. -.SS "lastlogin Command" -.sp -.LP -\fBlastlogin\fR is invoked by \fBrunacct\fR(8) to update -\fB/var/log/acct/sum/loginlog\fR, which shows the last date on which each -person logged in. -.SS "monacct Command" -.sp -.LP -\fBmonacct\fR should be invoked once each month or each accounting period. -\fInumber\fR indicates which month or period it is. If \fInumber\fR is not -given, it defaults to the current month (01\(mi12). This default is useful if -\fBmonacct\fR is to executed using \fBcron\fR(8) on the first day of each -month. \fBmonacct\fR creates summary files in \fB/var/log/acct/fiscal\fR and -restarts the summary files in \fB/var/log/acct/sum\fR. -.SS "nulladm Command" -.sp -.LP -\fBnulladm\fR creates \fIfilename\fR with mode 664 and ensures that owner and -group are \fBadm\fR. It is called by various accounting shell procedures. -.SS "prctmp Command" -.sp -.LP -\fBprctmp\fR can be used to print the session record file (normally -\fB/var/log/acct/nite/ctmp\fR created by \fBacctcon1\fR (see -\fBacctcon\fR(8)). -.SS "prdaily Command" -.sp -.LP -\fBprdaily\fR is invoked by \fBrunacct\fR(8) to format a report of the -previous day's accounting data. The report resides in -\fB/var/log/acct/sum/rprt/mmdd\fR where \fImmdd\fR is the month and day of the -report. The current daily accounting reports may be printed by typing -\fBprdaily\fR. Previous days' accounting reports can be printed by using the -\fImmdd\fR option and specifying the exact report date desired. -.SS "prtacct Command" -.sp -.LP -\fBprtacct\fR can be used to format and print any total accounting -(\fBtacct\fR)file. -.SS "shutacct Command" -.sp -.LP -\fBshutacct\fR is invoked during a system shutdown to turn process accounting -off and append a \fIreason\fR record to \fB/var/log/wtmpx\fR. -.SS "startup Command" -.sp -.LP -\fBstartup\fR can be invoked when the system is brought to a multi-user state -to turn process accounting on. -.SS "turnacct Command" -.sp -.LP -\fBturnacct\fR is an interface to \fBaccton\fR (see \fBacct\fR(8)) to turn -process accounting \fBon\fR or \fBoff\fR. The \fBswitch\fR argument moves the -current \fB/var/log/pacct\fR to the next free name in -\fB/var/log/pacct.\fIincr\fR\fR (where \fIincr\fR is a number starting with -\fB0\fR and incrementing by one for each additional \fBpacct\fR file), then -turns accounting back on again. This procedure is called by \fBckpacct\fR and -thus can be taken care of by the \fBcron\fR(8) command and used to keep \fB -pacct\fR to a reasonable size. \fBshutacct\fR uses \fBturnacct\fR to stop -process accounting. \fBstartup\fR uses \fBturnacct\fR to start process -accounting. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-c\fR\fR -.ad -.RS 6n -This option prints a report of exceptional resource usage by command, and may -be used on current day's accounting data only. -.RE - -.sp -.ne 2 -.na -\fB\fB-l\fR\fR -.ad -.RS 6n -This option prints a report of exceptional usage by login id for the specified -date. Previous daily reports are cleaned up and therefore inaccessible after -each invocation of \fBmonacct\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-o\fR\fR -.ad -.RS 6n -This option uses \fBacctdusg\fR (see \fBacct\fR(8)) to do a slower version of -disk accounting by login directory. \fIfilename\fRs specifies the one or more -filesystem names where disk accounting will be done. If \fIfilename\fRs are -used, disk accounting will be done on these filesystems only. If the \fB-o\fR -option is used, \fIfilename\fRs should be mount points of mounted filesystems. -If the \fB-o\fR option is omitted, \fIfilename\fRs should be the special file -names of mountable filesystems. -.RE - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/etc/logadm.conf\fR\fR -.ad -.RS 30n -Configuration file for the \fBlogadm\fR(8) command -.RE - -.sp -.ne 2 -.na -\fB\fB/usr/lib/acct\fR\fR -.ad -.RS 30n -Holds all accounting commands listed in section \fB1M\fR of this manual -.RE - -.sp -.ne 2 -.na -\fB\fB/usr/lib/acct/ptecms.awk\fR\fR -.ad -.RS 30n -Contains the limits for exceptional usage by command name -.RE - -.sp -.ne 2 -.na -\fB\fB/usr/lib/acct/ptelus.awk\fR\fR -.ad -.RS 30n -Contains the limits for exceptional usage by login \fBID\fR -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/fiscal\fR\fR -.ad -.RS 30n -Fiscal reports directory -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/nite\fR\fR -.ad -.RS 30n -Working directory -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/sum\fR\fR -.ad -.RS 30n -Summary directory that contains information for \fBmonacct\fR -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/sum/loginlog\fR\fR -.ad -.RS 30n -File updated by last login -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/fee\fR\fR -.ad -.RS 30n -Accumulator for fees -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/pacct\fR\fR -.ad -.RS 30n -Current file for per-process accounting -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/pacct\fR\fIincr\fR\fR -.ad -.RS 30n -Used if \fBpacct\fR gets large and during execution of daily accounting -procedure -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/wtmpx\fR\fR -.ad -.RS 30n -History of user access and administration information -.RE - -.SH SEE ALSO -.sp -.LP -\fBacctcom\fR(1), \fBacct\fR(8), \fBacctcms\fR(8), \fBacctcon\fR(8), -\fBacctmerg\fR(8), \fBacctprc\fR(8), \fBcron\fR(8), \fBfwtmp\fR(8), -\fBlogadm\fR(8), \fBrunacct\fR(8), \fBacct\fR(2), \fBacct.h\fR(3HEAD), -\fButmpx\fR(4), \fBattributes\fR(5) -.SH NOTES -.sp -.LP -See \fBrunacct\fR(8) for the main daily accounting shell script, which -performs the accumulation of connect, process, fee, and disk accounting on a -daily basis. It also creates summaries of command usage.
--- a/share/man/man8/fwtmp.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH FWTMP 8 "Feb 22, 1999" -.SH NAME -fwtmp, wtmpfix \- manipulate connect accounting records -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/acct/fwtmp\fR [\fB-ic\fR] -.fi - -.LP -.nf -\fB/usr/lib/acct/wtmpfix\fR [\fIfile\fR]... -.fi - -.SH DESCRIPTION -.sp -.LP -\fBfwtmp\fR reads from the standard input and writes to the standard output, -converting binary records of the type found in \fB/var/log/wtmpx\fR to -formatted ASCII records. The ASCII version is useful when it is necessary to -edit bad records. -.sp -.LP -\fBwtmpfix\fR examines the standard input or named files in \fButmpx\fR format, -corrects the time/date stamps to make the entries consistent, and writes to the -standard output. A hyphen (\fB\(mi\fR) can be used in place of \fIfile\fR to -indicate the standard input. If time/date corrections are not performed, -\fBacctcon\fR(8) will fault when it encounters certain date-change records. -.sp -.LP -Each time the date is set, a pair of date change records are written to -\fB/var/log/wtmpx\fR. The first record is the old date denoted by the string -"\fBold time\fR" placed in the \fBline\fR field and the flag -\fB\fR\fBOLD_TIME\fR\fB\fR placed in the \fBtype\fR field of the \fButmpx\fR -structure. The second record specifies the new date and is denoted by the -string \fBnew time\fR placed in the \fBline\fR field and the flag -\fB\fR\fBNEW_TIME\fR\fB\fR placed in the \fBtype\fR field. \fBwtmpfix\fR uses -these records to synchronize all time stamps in the file. -.sp -.LP -In addition to correcting time/date stamps, \fBwtmpfix\fR will check the -validity of the \fBname\fR field to ensure that it consists solely of -alphanumeric characters or spaces. If it encounters a name that is considered -invalid, it will change the login name to \fB\fR\fBINVALID\fR\fB\fR and write a -diagnostic to the standard error. In this way, \fBwtmpfix\fR reduces the chance -that \fBacctcon\fR will fail when processing connect accounting records. -.SH OPTIONS -.sp -.ne 2 -.na -\fB\fB-ic\fR\fR -.ad -.RS 7n -Denotes that input is in ASCII form, and output is to be written in binary -form. -.RE - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/var/log/wtmpx\fR\fR -.ad -.RS 18n -history of user access and administration information -.RE - -.SH SEE ALSO -.sp -.LP -\fBacctcom\fR(1), \fBed\fR(1), \fBacct\fR(8), \fBacctcms\fR(8), -\fBacctcon\fR(8), \fBacctmerg\fR(8), \fBacctprc\fR(8), \fBacctsh\fR(8), -\fBrunacct\fR(8), \fBacct\fR(2), \fBacct.h\fR(3HEAD), \fButmpx\fR(4), -\fBattributes\fR(5) -.sp -.LP -\fI\fR
--- a/share/man/man8/runacct.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,322 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH RUNACCT 8 "May 11, 1999" -.SH NAME -runacct \- run daily accounting -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/acct/runacct\fR [\fImmdd\fR [\fIstate\fR]] -.fi - -.SH DESCRIPTION -.sp -.LP -\fBrunacct\fR is the main daily accounting shell procedure. It is normally -initiated using \fBcron\fR. \fBrunacct\fR processes connect, fee, disk, and -process accounting files. It also prepares summary files for \fBprdaily\fR or -billing purposes. \fBrunacct\fR is distributed only to source code licensees. -.sp -.LP -\fBrunacct\fR takes care not to damage active accounting files or summary files -in the event of errors. It records its progress by writing descriptive -diagnostic messages into \fBactive\fR. When an error is detected, a message is -written to \fB/dev/console\fR, mail (see \fBmail\fR(1)) is sent to \fBroot\fR -and \fBadm\fR, and \fBrunacct\fR terminates. \fBrunacct\fR uses a series of -lock files to protect against re-invocation. The files \fBlock\fR and -\fBlock1\fR are used to prevent simultaneous invocation, and \fBlastdate\fR is -used to prevent more than one invocation per day. -.sp -.LP -\fBrunacct\fR breaks its processing into separate, restartable \fIstates\fR -using \fBstatefile\fR to remember the last \fIstate\fR completed. It -accomplishes this by writing the \fIstate\fR name into \fBstatefile\fR. -\fBrunacct\fR then looks in \fBstatefile\fR to see what it has done and to -determine what to process next. \fIstates\fR are executed in the following -order: -.sp -.ne 2 -.na -\fB\fBSETUP\fR\fR -.ad -.RS 14n -Move active accounting files into working files. -.RE - -.sp -.ne 2 -.na -\fB\fBWTMPFIX\fR\fR -.ad -.RS 14n -Verify integrity of \fBwtmpx\fR file, correcting date changes if necessary. -.RE - -.sp -.ne 2 -.na -\fB\fBCONNECT\fR\fR -.ad -.RS 14n -Produce connect session records in \fBtacct.h\fR format. -.RE - -.sp -.ne 2 -.na -\fB\fBPROCESS\fR\fR -.ad -.RS 14n -Convert process accounting records into \fBtacct.h\fR format. -.RE - -.sp -.ne 2 -.na -\fB\fBMERGE\fR\fR -.ad -.RS 14n -Merge the connect and process accounting records. -.RE - -.sp -.ne 2 -.na -\fB\fBFEES\fR\fR -.ad -.RS 14n -Convert output of \fBchargefee\fR into \fBtacct.h\fR format, merge with -connect, and process accounting records. -.RE - -.sp -.ne 2 -.na -\fB\fBDISK\fR\fR -.ad -.RS 14n -Merge disk accounting records with connect, process, and fee accounting -records. -.RE - -.sp -.ne 2 -.na -\fB\fBMERGETACCT\fR\fR -.ad -.RS 14n -Merge the daily total accounting records in \fBdaytacct\fR with the summary -total accounting records in \fB/var/log/acct/sum/tacct\fR. -.RE - -.sp -.ne 2 -.na -\fB\fBCMS\fR\fR -.ad -.RS 14n -Produce command summaries. -.RE - -.sp -.ne 2 -.na -\fB\fBUSEREXIT\fR\fR -.ad -.RS 14n -Any installation dependent accounting programs can be included here. -.RE - -.sp -.ne 2 -.na -\fB\fBCLEANUP\fR\fR -.ad -.RS 14n -Clean up temporary files and exit. To restart \fBrunacct\fR after a failure, -first check the \fBactive\fR file for diagnostics, then fix any corrupted data -files, such as \fBpacct\fR or \fBwtmpx\fR. The \fBlock\fR, \fBlock1\fR, and -\fBlastdate\fR files must be removed before \fBrunacct\fR can be restarted. -The argument \fImmdd\fR is necessary if \fBrunacct\fR is being restarted. -\fImmdd\fR specifies the month and day for which \fBrunacct\fR will rerun the -accounting. The entry point for processing is based on the contents of \fB -statefile\fR; to override this, include the desired \fIstate\fR on the command -line to designate where processing should begin. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRStarting \fBrunacct\fR -.sp -.LP -The following example starts \fBrunacct\fR: - -.sp -.in +2 -.nf -example% nohup runacct 2> /var/log/acct/nite/fd2log & -.fi -.in -2 -.sp - -.LP -\fBExample 2 \fRRestarting \fBrunacct\fR -.sp -.LP -The following example restarts \fBrunacct\fR: - -.sp -.in +2 -.nf -example% nohup runacct 0601 2>> /var/log/acct/nite/fd2log & -.fi -.in -2 -.sp - -.LP -\fBExample 3 \fRRestarting \fBrunacct\fR at a Specific State -.sp -.LP -The following example restarts \fBrunacct\fR at a specific state: - -.sp -.in +2 -.nf -example% nohup runacct 0601 MERGE 2>> /var/log/acct/nite/fd2log & -.fi -.in -2 -.sp - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/var/log/wtmpx\fR\fR -.ad -.sp .6 -.RS 4n -History of user access and administration information -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/pacct\fR\fIincr\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/nite/active\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/nite/daytacct\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/nite/lock\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/nite/lock1\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/nite/lastdate\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/acct/nite/statefile\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.SH SEE ALSO -.sp -.LP -\fBacctcom\fR(1), \fBmail\fR(1), \fBacct\fR(8), \fBacctcms\fR(8), -\fBacctcon\fR(8), \fBacctmerg\fR(8), \fBacctprc\fR(8), \fBacctsh\fR(8), -\fBcron\fR(8), \fBfwtmp\fR(8), \fBacct\fR(2), \fBacct.h\fR(3HEAD), -\fButmpx\fR(4), \fBattributes\fR(5) -.SH NOTES -.sp -.LP -It is not recommended to restart \fBrunacct\fR in the \fBSETUP\fR \fIstate\fR. -Run \fBSETUP\fR manually and restart using: -.sp -.LP -\fBrunacct\fR \fImmdd\fR \fBWTMPFIX\fR -.sp -.LP -If \fBrunacct\fR failed in the \fBPROCESS\fR \fIstate,\fR remove the last -\fBptacct\fR file because it will not be complete. -.sp -.LP -The \fBrunacct\fR command can process a maximum of -.RS +4 -.TP -.ie t \(bu -.el o -6000 distinct sessions -.RE -.RS +4 -.TP -.ie t \(bu -.el o -1000 distinct terminal lines -.RE -.RS +4 -.TP -.ie t \(bu -.el o -2000 distinct login names -.RE -.sp -.LP -during a single invocation of the command. If at some point the actual number -of any one of these items exceeds the maximum, the command will not succeed. -.sp -.LP -Do not invoke \fBrunacct\fR at the same time as \fBckpacct\fR, as there may be -a conflict if both scripts attempt to execute \fBturnacct switch\fR -simultaneously.
--- a/share/man/man8/sar.8 Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH SAR 8 "May 13, 2017" -.SH NAME -sar, sa1, sa2, sadc \- system activity report package -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/sa/sadc\fR [\fIt\fR \fIn\fR] [\fIofile\fR] -.fi - -.LP -.nf -\fB/usr/lib/sa/sa1\fR [\fIt\fR \fIn\fR] -.fi - -.LP -.nf -\fB/usr/lib/sa/sa2\fR [\fB-aAbcdgkmpqruvwy\fR] [\fB-e\fR \fItime\fR] [\fB-f\fR \fIfilename\fR] - [\fB-i\fR \fIsec\fR] [\fB-s\fR \fItime\fR] -.fi - -.SH DESCRIPTION -.LP -System activity data can be accessed at the special request of a user (see -\fBsar\fR(1)) and automatically, on a routine basis, as described here. The -operating system contains several counters that are incremented as various -system actions occur. These include counters for \fBCPU\fR utilization, buffer -usage, disk and tape \fBI/O\fR activity, \fBTTY\fR device activity, switching -and system-call activity, file-access, queue activity, inter-process -communications, and paging. For more general system statistics, use -\fBiostat\fR(8), \fBsar\fR(1), or \fBvmstat\fR(8). -.sp -.LP -\fBsadc\fR and two shell procedures, \fBsa1\fR and \fBsa2\fR, are used to -sample, save, and process this data. -.sp -.LP -\fBsadc\fR, the data collector, samples system data \fIn\fR times, with an -interval of \fIt\fR seconds between samples, and writes in binary format to -\fIofile\fR or to standard output. The sampling interval \fIt\fR should be -greater than 5 seconds; otherwise, the activity of \fBsadc\fR itself may affect -the sample. If \fIt\fR and \fIn\fR are omitted, a special record is written. -This facility can be used at system boot time, when booting to a multi-user -state, to mark the time at which the counters restart from zero. For example, -when accounting is enabled, the \fBsvc:/system/sar:default\fR service writes -the restart mark to the daily data file using the command entry: -.sp -.in +2 -.nf -su sys -c "/usr/lib/sa/sadc /var/log/sa/sa\&'date +%d\&'" -.fi -.in -2 -.sp - -.sp -.LP -The shell script \fBsa1\fR, a variant of \fBsadc\fR, is used to collect and -store data in the binary file \fB/var/log/sa/sa\fR\fIdd,\fR where \fBdd\fR is -the current day. The arguments \fIt\fR and \fIn\fR cause records to be written -\fIn\fR times at an interval of \fIt\fR seconds, or once if omitted. The -following entries in \fB/var/spool/cron/crontabs/sys\fR will produce records -every 20 minutes during working hours and hourly otherwise: -.sp -.in +2 -.nf -0 * * * 0-6 /usr/lib/sa/sa1 -20,40 8\(mi17 * * 1\(mi5 /usr/lib/sa/sa1 -.fi -.in -2 -.sp - -.sp -.LP -See \fBcrontab\fR(1) for details. -.sp -.LP -The shell script \fBsa2\fR, a variant of \fBsar\fR, writes a daily report in -the file \fB/var/log/sa/sar\fR\fIdd.\fR See the \fBOPTIONS\fR section in -\fBsar\fR(1) for an explanation of the various options. The following entry in -\fB/var/spool/cron/crontabs/sys\fR will report important activities hourly -during the working day: -.sp -.in +2 -.nf -5 18 * * 1\(mi5 /usr/lib/sa/sa2 \fB-s\fR 8:00 \fB-e\fR 18:01 \fB-i\fR 1200 \fB-A\fR -.fi -.in -2 -.sp - -.SH FILES -.ne 2 -.na -\fB\fB/tmp/sa.adrfl\fR\fR -.ad -.sp .6 -.RS 4n -address file -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/sa/sa\fR\fBdd\fR\fR -.ad -.sp .6 -.RS 4n -Daily data file -.RE - -.sp -.ne 2 -.na -\fB\fB/var/log/sa/sar\fR\fBdd\fR\fR -.ad -.sp .6 -.RS 4n -Daily report file -.RE - -.sp -.ne 2 -.na -\fB\fB/var/spool/cron/crontabs/sys\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.SH SEE ALSO -.LP -\fBcrontab\fR(1), \fBsar\fR(1), \fBsvcs\fR(1), \fBtimex\fR(1), -\fBiostat\fR(8), \fBsvcadm\fR(8), \fBvmstat\fR(8), \fBattributes\fR(5), -\fBsmf\fR(5) -.sp -.LP -\fI\fR -.SH NOTES -.LP -The \fBsar\fR service is managed by the service management facility, -\fBsmf\fR(5), under the service identifier: -.sp -.in +2 -.nf -svc:/system/sar -.fi -.in -2 -.sp - -.sp -.LP -Administrative actions on this service, such as enabling, disabling, or -requesting restart, can be performed using \fBsvcadm\fR(8). The service's -status can be queried using the \fBsvcs\fR(1) command.
--- a/usr/src/Targetdirs Mon May 20 17:16:39 2019 -0400 +++ b/usr/src/Targetdirs Mon May 20 19:46:49 2019 -0400 @@ -254,7 +254,6 @@ $(PYTHON2_DIRS) \ /usr/lib/rcap \ /usr/lib/rcap/$(MACH32) \ - /usr/lib/sa \ /usr/lib/saf \ /usr/lib/sasl \ /usr/lib/scsi \ @@ -293,7 +292,6 @@ /var/log \ /var/log/exacct \ /var/log/pool \ - /var/log/sa \ /var/log/streams \ /var/log/svc \ /var/logadm \ @@ -428,8 +426,6 @@ # The default value for DIRMODE is specified in usr/src/Makefile.master. # -$(ROOT)/var/log/sa := DIRMODE= 775 - $(ROOT)/var/spool/lp:= DIRMODE= 775 # file mode
--- a/usr/src/cmd/Adm/Makefile Mon May 20 17:16:39 2019 -0400 +++ b/usr/src/cmd/Adm/Makefile Mon May 20 19:46:49 2019 -0400 @@ -23,7 +23,7 @@ # Use is subject to license terms. # -CRON_ENT= adm root sys +CRON_ENT= adm root CRON_LIB= .proto at.deny cron.deny queuedefs ETC_SCRIPT= group project ttysrch mailcap mime.types ZI_SPECIAL= zones-index @@ -51,7 +51,6 @@ $(CRONLIBD)/.proto := FILEMODE = 0744 $(CRONTABD)/adm := FILEMODE = 0600 -$(CRONTABD)/sys := FILEMODE = 0600 $(CRONTABD)/root := FILEMODE = 0600 .KEEP_STATE:
--- a/usr/src/cmd/Adm/sys Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# The sys crontab should be used to do performance collection. See cron -# and performance manual pages for details on startup. -#
--- a/usr/src/cmd/Makefile Mon May 20 17:16:39 2019 -0400 +++ b/usr/src/cmd/Makefile Mon May 20 19:46:49 2019 -0400 @@ -52,7 +52,6 @@ perl \ Adm \ abi \ - acct \ acctadm \ ahciem \ ast \ @@ -300,7 +299,6 @@ rpcinfo \ rpcsvc \ runat \ - sa \ saf \ sasinfo \ savecore \
--- a/usr/src/cmd/Makefile.check Mon May 20 17:16:39 2019 -0400 +++ b/usr/src/cmd/Makefile.check Mon May 20 19:46:49 2019 -0400 @@ -56,7 +56,6 @@ rmvolmgr \ rpcbind \ rpcsvc \ - sa \ saf \ smserverd \ stmfsvc \
--- a/usr/src/cmd/acct/Makefile Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2015 Gary Mills -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# Copyright (c) 2018, Joyent, Inc. - -PROG= acctcms acctcom acctcon acctcon1 acctcon2 \ - acctdisk acctdusg acctmerg accton acctprc acctprc1 \ - acctprc2 acctwtmp closewtmp fwtmp \ - wtmpfix utmp2wtmp -SHFILE1= acct chargefee ckpacct dodisk lastlogin\ - monacct nulladm prctmp prdaily prtacct \ - remove runacct shutacct startup turnacct -SHFILE2= ptecms.awk ptelus.awk -SUBDIRS= lib -ALL= $(PROG) $(SHFILE1) $(SHFILE2) holidays - -SRCS= $(PROG:%=%.c) -SHFILE1SRCS= $(SHFILE1:%=%.sh) - -BINPROG= acctcom -LIBPROG= acctcms acctcon acctcon1 acctcon2 acctdisk \ - acctdusg acctmerg accton acctprc acctprc1 acctprc2 \ - acctwtmp closewtmp fwtmp utmp2wtmp \ - wtmpfix chargefee ckpacct dodisk monacct \ - lastlogin nulladm prctmp prdaily prtacct \ - remove runacct shutacct startup turnacct \ - ptecms.awk ptelus.awk -ETCPROG= holidays -INITPROG= acct - -include ../Makefile.cmd - -all:= TARGET= all -install:= TARGET= install -clean:= TARGET= clean -clobber:= TARGET= clobber - -acctcom := LDLIBS += lib/a.a -acctcms acctcon acctcon1 acctmerg acctprc1 acctprc := LDLIBS += lib/a.a - -acctdusg:= LDLIBS += -lcmdutils - -LIBACCTD= $(ROOTLIB)/acct -ETCACCTD= $(ROOTETC)/acct -ETCINITD= $(ROOTETC)/init.d -VARADMD= $(ROOT)/var/log -ACCTDIR= $(VARADMD)/acct -ACCTSUBDIRS= $(ACCTDIR)/nite $(ACCTDIR)/fiscal $(ACCTDIR)/sum -WKDIRS= $(ACCTDIR) $(ACCTSUBDIRS) - -# DIRS is directories to create. $(ETCINITD) [aka: /etc/init.d] is created -# in /usr/src/Targetdirs and hence should be assumed to exist. -DIRS= $(LIBACCTD) $(ETCACCTD) $(WKDIRS) - -USRBINPROG= $(BINPROG:%=$(ROOTBIN)/%) -LIBACCTPROG= $(LIBPROG:%=$(LIBACCTD)/%) -ETCACCTPROG= $(ETCPROG:%=$(ETCACCTD)/%) -ETCINITPROG= $(INITPROG:%=$(ETCINITD)/%) - -$(LIBACCTD) := DIRMODE= 755 -$(ETCACCTD) := DIRMODE= 755 -$(WKDIRS) := DIRMODE= 775 -$(LIBACCTD)/accton := FILEMODE= 04755 -$(ETCINITPROG) := FILEMODE= 0744 -$(ETCACCTPROG) := FILEMODE= 0644 - -CERRWARN += -Wno-implicit-function-declaration -CERRWARN += -Wno-parentheses -CERRWARN += -Wno-unused-variable -CERRWARN += -Wno-address - -# not linted -SMATCH=off - -.KEEP_STATE: - -.PARALLEL: $(ALL) - -all: $(SUBDIRS) .WAIT $(ALL) - -install: all .WAIT $(DIRS) .WAIT $(USRBINPROG) $(LIBACCTPROG) $(ETCACCTPROG) \ - $(ETCINITPROG) - -THIS_YEAR:sh= date +%Y - -holidays: FRC - @if grep $(THIS_YEAR) holidays > /dev/null 2>&1;\ - then \ - :;\ - else \ - $(ECHO) "building holidays";\ - ( \ - $(ECHO) "* @(#)holidays\tJanuary 1, `date +%Y`";\ - $(ECHO) "*";\ - $(ECHO) "* Prime/Nonprime Table for UNIX Accounting System";\ - $(ECHO) "*";\ - $(ECHO) "* Curr\tPrime\tNon-Prime";\ - $(ECHO) "* Year\tStart\tStart";\ - $(ECHO) "*";\ - $(ECHO) " `date +%Y`\t0800\t1800";\ - $(ECHO) "*";\ - $(ECHO) "* only the first column (month/day) is significiant.";\ - $(ECHO) "*";\ - $(ECHO) "* month/day\tCompany";\ - $(ECHO) "* \t\tHoliday";\ - $(ECHO) "*";\ - $(ECHO) "1/1\t\tNew Years Day";\ - $(ECHO) "7/4\t\tIndep. Day";\ - $(ECHO) "12/25\t\tChristmas" ) > holidays;\ - fi - -$(DIRS): - $(INS.dir) - -$(LIBACCTD)/% : % - $(INS.file) - -$(ETCACCTD)/% : % - $(INS.file) - -$(ETCINITD)/% : % - $(INS.file) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET) - -FRC: - -clean: $(SUBDIRS) - -clobber: $(SUBDIRS) - $(RM) $(PROG) $(SHFILE1) holidays
--- a/usr/src/cmd/acct/acct.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. -# All rights reserved. -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" - -state="$1" - -case "$state" in -'start') - echo 'Starting process accounting' - /usr/lib/acct/startup - ;; - -'stop') - echo 'Stopping process accounting' - /usr/lib/acct/shutacct - ;; - -*) - echo "Usage: $0 { start | stop }" - exit 1 - ;; -esac -exit 0
--- a/usr/src/cmd/acct/acctcms.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,855 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * acctcms [-a] [-c] [-j] [-n] [-s] [-p] [-o] [-t] [file...] - * summarize per-process accounting - * -a output in ascii, rather than [pt]cms.h format - * -c sort by total cpu, rather than total kcore-minutes - * -j anything used only once -> ***other - * -n sort by number of processes - * -s any following files already in pcms.h format - * -p output prime time command summary (only with -a) - * -o output non-prime time (offshift) command summary (only - * with -a option) - * -t process records in total (old) style (tcms.h) format - * file file in [pt]cms.h (if -s seen already) or acct.h (if not) - * expected use: - * acctcms /var/log/pacct? > today; acctcms -s old today >new - * cp new old; rm new - * acctcms -a today; acctcms -a old - */ -#include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <ctype.h> -#include <string.h> -#include <sys/acct.h> -#include <stdlib.h> - -int csize = CSIZE; - -/* - * Total cms records format - */ -struct tcms { - char tcm_comm[8]; /* command name */ - long tcm_pc; /* number of processes */ - float tcm_cpu; /* cpu time(min) */ - float tcm_real; /* real time(min) */ - float tcm_kcore; /* kcore-minutes */ - ulong_t tcm_io; /* chars transferred */ - ulong_t tcm_rw; /* blocks read */ -} ; -struct tcms *tcm; -/* - * prime/nonprime CMS record format - */ -struct pcms { - char pcm_comm[8]; /* command name */ - long pcm_pc[2]; /* number of processes */ - float pcm_cpu[2]; /* cpu time(min) */ - float pcm_real[2]; /* real time(min) */ - float pcm_kcore[2]; /* kcore-minutes */ - float pcm_io[2]; /* chars transferred */ - float pcm_rw[2]; /* blocks read */ -} ; -struct pcms *pcm; -struct tcms tcmtmp = {{'*','*','*','o','t','h','e','r'}}; -struct pcms pcmtmp = {{'*','*','*','o','t','h','e','r'}}; -int aflg; -int cflg; -int jflg; -int nflg; -int sflg; -int pflg; -int oflg; -int tflg; -int errflg; - -#ifdef uts -float expand(); -#else -ulong_t expand(); -#endif - -void outputc(void); -void totprnt(struct pcms *); -void pprint(struct pcms *); -void prnt(struct pcms *, int); -void print(struct pcms *); -void outputa(void); -void toutptc(void); -void tprint(struct tcms *); -void toutpta(void); -int ncmp(struct pcms *, struct pcms *); -int tncmp(struct tcms *, struct tcms *); -int tccmp(struct tcms *, struct tcms *); -int tkcmp(struct tcms *, struct tcms *); -int ccmp(struct pcms *, struct pcms *); -int kcmp(struct pcms *, struct pcms *); -void tdofile(char *); -void dofile(char *); -void tfixjunk(void); -void fixjunk(void); -void tcmadd(struct tcms *, struct tcms *); -void pcmadd(struct pcms *, struct pcms *); -void tsqueeze(void); -void squeeze(void); - -/* Format specification for ASCII printing */ - -char *fmtcmd = "%-8.8s", - *fmtcnt = "%8ld", - *fmtkcore = " %11.2f", - *fmtcpu = " %9.2f", - *fmtreal = " %12.2f", - *fmtmsz = " %7.2f", - *fmtmcpu = " %6.2f", - *fmthog = " %5.2f", - *fmtcharx = " %12.0f", - *fmtblkx = " %10.0f" ; - -int -main(int argc, char **argv) -{ - int c; - - while((c = getopt(argc, argv, "acjnspot")) != EOF) - switch(c) { - case 'a': - aflg++; - continue; - case 'c': - cflg++; - continue; - case 'j': - jflg++; - continue; - case 'n': - nflg++; - continue; - case 's': - sflg++; - continue; - case 'p': - pflg++; - continue; - case 'o': - oflg++; - continue; - case 't': - tflg++; - continue; - default: - errflg++; - continue; - } - if(errflg){ - fprintf(stderr, "Usage: %s [-acjnspot] [file ...]\n", argv[0]); - exit(1); - } - if(tflg) { - if( (tcm = (struct tcms *)calloc(CSIZE, sizeof(struct tcms))) == NULL) { - fprintf(stderr, "%s: Cannot allocate memory\n", argv[0]); - exit(5); - } - for(; optind < argc; optind++) - tdofile(argv[optind]); - if (jflg) - tfixjunk(); - tsqueeze(); - qsort(tcm, csize, sizeof(tcm[0]), - (int (*)(const void *, const void *)) - ( nflg ? tncmp: (cflg? tccmp: tkcmp))); - if (aflg) - toutpta(); - else - toutptc(); - } else { - if( (pcm = (struct pcms *)calloc(CSIZE, sizeof(struct pcms))) == NULL) { - fprintf(stderr, "%s: Cannot allocate memory\n", argv[0]); - exit(6); - } - for(; optind < argc; optind++) - dofile(argv[optind]); - if (jflg) - fixjunk(); - squeeze(); - qsort(pcm, csize, sizeof(pcm[0]), - (int (*)(const void *, const void *)) - (nflg? ncmp: (cflg? ccmp: kcmp))); - if (aflg) - outputa(); - else - outputc(); - } - exit(0); - -} - -void -tdofile(char *fname) -{ - struct tcms cmt; - union { - struct acct ab; /* SVR4 acct structure */ - struct o_acct oab; /* SVR3 acct structure */ - } acct; - int ver = 0; - ulong_t mem; - ulong_t cpu; - ulong_t real; - - if (freopen(fname, "r", stdin) == NULL) { - fprintf(stderr, "acctcms: cannot open %s\n", fname); - return; - } - - if (sflg) - while (fread(&cmt, sizeof(cmt), 1, stdin) == 1) - tenter(&cmt); - else { - if (fread(&acct.ab, sizeof(acct.ab), 1, stdin) == 1) - /* check for expanded account structure flag */ - if (acct.ab.ac_flag & AEXPND) - ver = 2; /* 4.0 acct file */ - else - ver = 1; /* SVR3.x acct file */ - - rewind(stdin); /* reset file pointer */ - - switch(ver) { - - default: - /* this can't happen */ - fprintf(stderr, "acctcms: encountered bad version number\n"); - return; - case 1 : - while (fread(&acct.oab, sizeof(acct.oab), 1, stdin) == 1) { - CPYN(cmt.tcm_comm, acct.oab.ac_comm); - cmt.tcm_pc = 1; - cpu = expand(acct.oab.ac_stime)+ - expand(acct.oab.ac_utime); - cmt.tcm_cpu = MINT(cpu); - real = expand(acct.oab.ac_etime); - cmt.tcm_real = MINT(real); - mem = expand(acct.oab.ac_mem); - cmt.tcm_kcore = MINT(KCORE(mem)); - cmt.tcm_io = expand(acct.oab.ac_io); - cmt.tcm_rw = expand(acct.oab.ac_rw); - tenter(&cmt); - } - break; - case 2 : - - while (fread(&acct.ab, sizeof(acct.ab), 1, stdin) == 1) { - CPYN(cmt.tcm_comm, acct.ab.ac_comm); - cmt.tcm_pc = 1; - cpu = expand(acct.oab.ac_stime)+ - expand(acct.oab.ac_utime); - cmt.tcm_cpu = MINT(cpu); - real = expand(acct.ab.ac_etime); - cmt.tcm_real = MINT(real); - mem = expand(acct.ab.ac_mem); - cmt.tcm_kcore = MINT(KCORE(mem)); - cmt.tcm_io = expand(acct.ab.ac_io); - cmt.tcm_rw = expand(acct.ab.ac_rw); - tenter(&cmt); - } - break; - } - } -} - -void -dofile(char *fname) -{ - union { - struct acct ab; - struct o_acct oab; - } acct; - struct pcms pcmt; - double ratio; - long elaps[2]; - ulong_t etime; - double dtmp; - unsigned long ltmp; - ulong_t mem; - ulong_t cpu; - ulong_t real; - - if (freopen(fname, "r", stdin) == NULL) { - fprintf(stderr, "acctcms: cannot open %s\n", fname); - return; - } - - if (sflg) - while (fread(&pcmt, sizeof(pcmt), 1, stdin) == 1) - enter(&pcmt); - else { - int ver = 0; - - if (fread(&acct.ab, sizeof(acct.ab), 1, stdin) == 1) - /* check for expanded account structure flag */ - if (acct.ab.ac_flag & AEXPND) - ver = 2; /* 4.0 acct file */ - else - ver = 1; /* SVR3.x acct file */ - - rewind(stdin); /* reset file pointer */ - - switch(ver) { - - default : - /* this can't happen */ - fprintf(stderr, "acctcms: encountered bad version number\n"); - return; - case 1 : - - while (fread(&acct.oab, sizeof(acct.oab), 1, stdin) == 1) { - CPYN(pcmt.pcm_comm, acct.oab.ac_comm); - /* - ** Approximate P/NP split as same as elapsed time - */ - if((etime = SECS(expand(acct.oab.ac_etime))) == 0) - etime = 1; - if (pnpsplit(acct.oab.ac_btime, etime, elaps) - == 0) { - (void) fprintf(stderr, "acctcms: could " - "not calculate prime/non-prime " - "hours\n"); - exit(1); - } - ratio = (double)elaps[PRIME]/(double)etime; - if(elaps[PRIME] > elaps[NONPRIME]) { - pcmt.pcm_pc[PRIME] = 1; - pcmt.pcm_pc[NONPRIME] = 0; - } else { - pcmt.pcm_pc[PRIME] = 0; - pcmt.pcm_pc[NONPRIME] = 1; - } - cpu = expand(acct.oab.ac_stime)+ - expand(acct.oab.ac_utime); - dtmp = MINT(cpu); - pcmt.pcm_cpu[PRIME] = dtmp * ratio; - pcmt.pcm_cpu[NONPRIME] = (ratio == 1.0) ? 0.0 : - (dtmp - pcmt.pcm_cpu[PRIME]); - real = expand(acct.oab.ac_etime); - dtmp = MINT(real); - pcmt.pcm_real[PRIME] = dtmp * ratio; - pcmt.pcm_real[NONPRIME] = (ratio == 1.0) ? 0.0 : - (dtmp - pcmt.pcm_real[PRIME]); - mem = expand(acct.oab.ac_mem); - dtmp = MINT(KCORE(mem)); - pcmt.pcm_kcore[PRIME] = dtmp * ratio; - pcmt.pcm_kcore[NONPRIME] = (ratio == 1.0) ? 0.0 : - (dtmp - pcmt.pcm_kcore[PRIME]); - ltmp = expand(acct.oab.ac_io); - pcmt.pcm_io[PRIME] = (double)ltmp * ratio; - pcmt.pcm_io[NONPRIME] = (ratio == 1.0) ? 0.0 : - ((double)ltmp - pcmt.pcm_io[PRIME]); - ltmp = expand(acct.oab.ac_rw); - pcmt.pcm_rw[PRIME] = (double)ltmp * ratio; - pcmt.pcm_rw[NONPRIME] = (ratio == 1.0) ? 0.0 : - ((double)ltmp - pcmt.pcm_rw[PRIME]); - enter(&pcmt); - } - - break; - case 2 : - while (fread(&acct.ab, sizeof(acct.ab), 1, stdin) == 1) { - CPYN(pcmt.pcm_comm, acct.ab.ac_comm); - /* - ** Approximate P/NP split as same as elapsed time - */ - if((etime = SECS(expand(acct.ab.ac_etime))) == 0) - etime = 1; - if(pnpsplit(acct.ab.ac_btime, etime, elaps) == 0) { - fprintf(stderr, "acctcms: could not calculate prime/non-prime hours\n"); - exit(1); - } - ratio = (double)elaps[PRIME]/(double)etime; - if(elaps[PRIME] > elaps[NONPRIME]) { - pcmt.pcm_pc[PRIME] = 1; - pcmt.pcm_pc[NONPRIME] = 0; - } else { - pcmt.pcm_pc[PRIME] = 0; - pcmt.pcm_pc[NONPRIME] = 1; - } - cpu = expand(acct.ab.ac_stime)+ - expand(acct.ab.ac_utime); - dtmp = MINT(cpu); - pcmt.pcm_cpu[PRIME] = dtmp * ratio; - pcmt.pcm_cpu[NONPRIME] = (ratio == 1.0) ? 0.0 : - (dtmp - pcmt.pcm_cpu[PRIME]); - real = expand(acct.ab.ac_etime); - dtmp = MINT(real); - pcmt.pcm_real[PRIME] = dtmp * ratio; - pcmt.pcm_real[NONPRIME] = (ratio == 1.0) ? 0.0 : - (dtmp - pcmt.pcm_real[PRIME]); - mem = expand(acct.ab.ac_mem); - dtmp = MINT(KCORE(mem)); - pcmt.pcm_kcore[PRIME] = dtmp * ratio; - pcmt.pcm_kcore[NONPRIME] = (ratio == 1.0) ? 0.0 : - (dtmp - pcmt.pcm_kcore[PRIME]); - ltmp = expand(acct.ab.ac_io); - pcmt.pcm_io[PRIME] = (double)ltmp * ratio; - pcmt.pcm_io[NONPRIME] = (ratio == 1.0) ? 0.0 : - ((double)ltmp - pcmt.pcm_io[PRIME]); - ltmp = expand(acct.ab.ac_rw); - pcmt.pcm_rw[PRIME] = (double)ltmp * ratio; - pcmt.pcm_rw[NONPRIME] = (ratio == 1.0) ? 0.0 : - ((double)ltmp - pcmt.pcm_rw[PRIME]); - enter(&pcmt); - } - - break; - } - } -} - -int -tenter(struct tcms *p) -{ - int i; - int j; - struct tcms *ntcm; - for (i = j = 0; j < sizeof(p->tcm_comm); j++) { - if (p->tcm_comm[j] && p->tcm_comm[j] <= 037) - p->tcm_comm[j] = '?'; - i = i*7 + p->tcm_comm[j]; /* hash function */ - } - if (i < 0) - i = -i; - for (i %= csize, j = 0; tcm[i].tcm_comm[0] && j != csize; i = (i+1)%csize, j++) - if (EQN(p->tcm_comm, tcm[i].tcm_comm)) - break; - if(j == csize) { - if ((ntcm = (struct tcms *) reallocarray(tcm, csize + CSIZE - 1, - sizeof (struct tcms))) == NULL) { - fprintf(stderr, - "acctcms: Cannot reallocate memory (tcm)\n"); - return(-1); - } else { - memset(&ntcm[csize], 0, CSIZE - 1); - tcm = ntcm; - if (!EQN(p->tcm_comm, tcm[i].tcm_comm)) - i = csize; - csize = csize + CSIZE - 1; - } - } - if (tcm[i].tcm_comm[0] == 0) - CPYN(tcm[i].tcm_comm, p->tcm_comm); - tcmadd(&tcm[i], p); - return(i); -} - -int -enter(struct pcms *p) -{ - int i; - int j; - struct pcms *npcm; - for (i = j = 0; j < sizeof(p->pcm_comm); j++) { - if (p->pcm_comm[j] && p->pcm_comm[j] <= 037) - p->pcm_comm[j] = '?'; - i = i*7 + p->pcm_comm[j]; /* hash function */ - } - if (i < 0) - i = -i; - for (i %= csize, j = 0; pcm[i].pcm_comm[0] && j != csize; i = (i+1)%csize, j++) - if (EQN(p->pcm_comm, pcm[i].pcm_comm)) - break; - if(j == csize) { - if ((npcm = reallocarray(pcm, csize + CSIZE - 1, - sizeof (struct pcms))) == NULL) { - fprintf(stderr, - "acctcms: Cannot reallocate memory (pcm)\n"); - return(-1); - } else { - memset(&npcm[csize], 0, CSIZE - 1); - pcm = npcm; - if (!EQN(p->pcm_comm, pcm[i].pcm_comm)) - i = csize; - csize = csize + CSIZE - 1; - } - } - if (pcm[i].pcm_comm[0] == 0) - CPYN(pcm[i].pcm_comm, p->pcm_comm); - pcmadd(&pcm[i], p); - return(i); -} - -void -tfixjunk(void) /* combine commands used only once */ -{ - int i, j; - j = tenter(&tcmtmp); - for (i = 0; i < csize; i++) - if (i != j && tcm[i].tcm_comm[0] && tcm[i].tcm_pc <= 1) { - tcmadd(&tcm[j], &tcm[i]); - tcm[i].tcm_comm[0] = 0; - } -} - -void -fixjunk(void) /* combine commands used only once */ -{ - int i, j; - j = enter(&pcmtmp); - for (i = 0; i < csize; i++) - if (i != j && pcm[i].pcm_comm[0] && (pcm[i].pcm_pc[PRIME] + pcm[i].pcm_pc[NONPRIME]) <= 1) { - pcmadd(&pcm[j], &pcm[i]); - pcm[i].pcm_comm[0] = 0; - } -} - -void -tcmadd(struct tcms *p1, struct tcms *p2) -{ - p1->tcm_pc += p2->tcm_pc; - p1->tcm_cpu = p1->tcm_cpu + p2->tcm_cpu; - p1->tcm_real = p1->tcm_real + p2->tcm_real; - p1->tcm_kcore = p1->tcm_kcore + p2->tcm_kcore; - p1->tcm_io += p2->tcm_io; - p1->tcm_rw += p2->tcm_rw; -} - -void -pcmadd(struct pcms *p1, struct pcms *p2) -{ - p1->pcm_pc[PRIME] += p2->pcm_pc[PRIME]; - p1->pcm_pc[NONPRIME] += p2->pcm_pc[NONPRIME]; - p1->pcm_cpu[PRIME] += p2->pcm_cpu[PRIME]; - p1->pcm_cpu[NONPRIME] += p2->pcm_cpu[NONPRIME]; - p1->pcm_real[PRIME] += p2->pcm_real[PRIME]; - p1->pcm_real[NONPRIME] += p2->pcm_real[NONPRIME]; - p1->pcm_kcore[PRIME] += p2->pcm_kcore[PRIME]; - p1->pcm_kcore[NONPRIME] += p2->pcm_kcore[NONPRIME]; - p1->pcm_io[PRIME] += p2->pcm_io[PRIME]; - p1->pcm_io[NONPRIME] += p2->pcm_io[NONPRIME]; - p1->pcm_rw[PRIME] += p2->pcm_rw[PRIME]; - p1->pcm_rw[NONPRIME] += p2->pcm_rw[NONPRIME]; -} - -void -tsqueeze(void) /* get rid of holes in hash table */ -{ - int i, k; - - for (i = k = 0; i < csize; i++) - if (tcm[i].tcm_comm[0]) { - CPYN(tcm[k].tcm_comm, tcm[i].tcm_comm); - tcm[k].tcm_pc = tcm[i].tcm_pc; - tcm[k].tcm_cpu = tcm[i].tcm_cpu; - tcm[k].tcm_real = tcm[i].tcm_real; - tcm[k].tcm_kcore = tcm[i].tcm_kcore; - tcm[k].tcm_io = tcm[i].tcm_io; - tcm[k].tcm_rw = tcm[i].tcm_rw; - k++; - } - csize = k; -} - -void -squeeze(void) /* get rid of holes in hash table */ -{ - int i, k; - - for (i = k = 0; i < csize; i++) - if (pcm[i].pcm_comm[0]) { - CPYN(pcm[k].pcm_comm, pcm[i].pcm_comm); - pcm[k].pcm_pc[PRIME] = pcm[i].pcm_pc[PRIME]; - pcm[k].pcm_pc[NONPRIME] = pcm[i].pcm_pc[NONPRIME]; - pcm[k].pcm_cpu[PRIME] = pcm[i].pcm_cpu[PRIME]; - pcm[k].pcm_cpu[NONPRIME] = pcm[i].pcm_cpu[NONPRIME]; - pcm[k].pcm_real[PRIME] = pcm[i].pcm_real[PRIME]; - pcm[k].pcm_real[NONPRIME] = pcm[i].pcm_real[NONPRIME]; - pcm[k].pcm_kcore[PRIME] = pcm[i].pcm_kcore[PRIME]; - pcm[k].pcm_kcore[NONPRIME] = pcm[i].pcm_kcore[NONPRIME]; - pcm[k].pcm_io[PRIME] = pcm[i].pcm_io[PRIME]; - pcm[k].pcm_io[NONPRIME] = pcm[i].pcm_io[NONPRIME]; - pcm[k].pcm_rw[PRIME] = pcm[i].pcm_rw[PRIME]; - pcm[k].pcm_rw[NONPRIME] = pcm[i].pcm_rw[NONPRIME]; - k++; - } - csize = k; -} - -int -tccmp(struct tcms *p1, struct tcms *p2) -{ - if (p1->tcm_cpu == p2->tcm_cpu) - return(0); - return ((p2->tcm_cpu > p1->tcm_cpu)? 1 : -1); -} - -int -ccmp(struct pcms *p1, struct pcms *p2) -{ - int index; - - if( (pflg && oflg) || (!pflg && !oflg) ) { - if (p1->pcm_cpu[PRIME] + p1->pcm_cpu[NONPRIME] == p2->pcm_cpu[PRIME] + p2->pcm_cpu[NONPRIME]) - return(0); - return ((p2->pcm_cpu[PRIME] + p2->pcm_cpu[NONPRIME] > p1->pcm_cpu[PRIME] + p1->pcm_cpu[NONPRIME])? 1 : -1); - } - index = pflg ? PRIME : NONPRIME; - if (p1->pcm_cpu[index] == p2->pcm_cpu[index]) - return(0); - return ((p2->pcm_cpu[index] > p1->pcm_cpu[index])? 1 : -1); -} - -int -tkcmp(struct tcms *p1, struct tcms *p2) -{ - if (p1->tcm_kcore == p2->tcm_kcore) - return(0); - return ((p2->tcm_kcore > p1->tcm_kcore)? 1 : -1); -} - -int -kcmp(struct pcms *p1, struct pcms *p2) -{ - int index; - - if( (pflg && oflg) || (!pflg && !pflg) ){ - if (p1->pcm_kcore[PRIME] + p1->pcm_kcore[NONPRIME] == p2->pcm_kcore[PRIME] + p2->pcm_kcore[NONPRIME]) - return(0); - return ((p2->pcm_kcore[PRIME] + p2->pcm_kcore[NONPRIME] > p1->pcm_kcore[PRIME] + p1->pcm_kcore[NONPRIME])? 1 : -1); - } - index = pflg ? PRIME : NONPRIME; - if (p1->pcm_kcore[index] == p2->pcm_kcore[index]) - return(0); - return ((p2->pcm_kcore[index] > p1->pcm_kcore[index])? 1 : -1); -} - -int -tncmp(struct tcms *p1, struct tcms *p2) -{ - if (p1->tcm_pc == p2->tcm_pc) - return(0); - return ((p2->tcm_pc > p1->tcm_pc)? 1 : -1); -} - -int -ncmp(struct pcms *p1, struct pcms *p2) -{ - int index; - - if( (pflg && oflg) || (!pflg && !oflg) ) { - if (p1->pcm_pc[PRIME] + p1->pcm_pc[NONPRIME] == p2->pcm_pc[PRIME] + p2->pcm_pc[NONPRIME]) - return(0); - return ((p2->pcm_pc[PRIME] + p2->pcm_pc[NONPRIME] > p1->pcm_pc[PRIME] + p1->pcm_pc[NONPRIME])? 1 : -1); - } - index = pflg ? PRIME : NONPRIME; - if (p1->pcm_pc[index] == p2->pcm_pc[index]) - return(0); - return ((p2->pcm_pc[index] > p1->pcm_pc[index])? 1 : -1); -} - -char thd1[] = -"COMMAND NUMBER TOTAL TOTAL TOTAL MEAN MEAN HOG CHARS BLOCKS\n"; -char thd2[] = -"NAME CMDS KCOREMIN CPU-MIN REAL-MIN SIZE-K CPU-MIN FACTOR TRNSFD READ\n"; - -void -toutpta(void) -{ - int i; - - printf(thd1); - printf(thd2); - printf("\n"); - for (i = 0; i < csize; i++) - tcmadd(&tcmtmp, &tcm[i]); - CPYN(tcmtmp.tcm_comm, "TOTALS"); - tprint(&tcmtmp); - printf("\n"); - for (i = 0; i < csize; i++) - tprint(&tcm[i]); -} - -void -tprint(struct tcms *p) -{ - printf("%-8.8s", p->tcm_comm); - printf(" %7ld", p->tcm_pc); - printf(" %11.2f", p->tcm_kcore); - printf(" %10.2f", p->tcm_cpu); - printf(" %12.2f", p->tcm_real); - if(p->tcm_cpu == 0) p->tcm_cpu = 1; - printf(" %6.2f", p->tcm_kcore/p->tcm_cpu); - if(p->tcm_pc == 0) p->tcm_pc = 1; - printf(" %7.2f", p->tcm_cpu/p->tcm_pc); - if (p->tcm_real == 0) - p->tcm_real = 1; - printf(" %8.2f", p->tcm_cpu/p->tcm_real); - printf(" %11lu", p->tcm_io); - printf(" %11lu\n", p->tcm_rw); -} - -void -toutptc(void) -{ - int i; - - for (i = 0; i < csize; i++) - fwrite(&tcm[i], sizeof(tcm[i]), 1, stdout); -} - -char hd1[] = -"COMMAND NUMBER TOTAL TOTAL TOTAL MEAN MEAN HOG CHARS BLOCKS\n"; -char hd2[] = -"NAME CMDS KCOREMIN CPU-MIN REAL-MIN SIZE-K CPU-MIN FACTOR TRNSFD READ\n"; -char hd3[] = -"COMMAND NUMBER TOTAL CPU-MIN REAL-MIN MEAN MEAN HOG CHARS BLOCKS\n"; -char hd4[] = -"NAME (P) (NP) KCOREMIN (P) (NP) (P) (NP) SIZE-K CPU-MIN FACTOR TRNSFD READ\n"; -char hdprime[] = -" PRIME TIME COMMAND SUMMARY\n"; -char hdnonprime[] = -" NON-PRIME TIME COMMAND SUMMARY\n"; -char hdtot[] = -" TOTAL COMMAND SUMMARY\n"; -char hdp[] = -" PRIME/NON-PRIME TIME COMMAND SUMMARY\n"; - -void -outputa(void) -{ - int i; - - if( pflg && oflg ) printf(hdp); - else if(pflg) printf(hdprime); - else if(oflg) printf(hdnonprime); - else printf(hdtot); - if( (!pflg && !oflg) || (pflg ^ oflg)) { - printf(hd1); - printf(hd2); - } - else { - printf(hd3); - printf(hd4); - } - printf("\n"); - for (i = 0; i < csize; i++) - pcmadd(&pcmtmp, &pcm[i]); - CPYN(pcmtmp.pcm_comm, "TOTALS"); - print(&pcmtmp); - printf("\n"); - for (i = 0; i < csize; i++) - print(&pcm[i]); -} - -void -print(struct pcms *p) -{ - if(pflg && oflg) pprint(p); - else if(pflg || oflg) prnt(p, pflg ? PRIME : NONPRIME); - else totprnt(p); -} - -void -prnt(struct pcms *p, int hr) -{ - if(p->pcm_pc[hr] == 0) return; - printf(fmtcmd, p->pcm_comm); - printf(fmtcnt, p->pcm_pc[hr]); - printf(fmtkcore, p->pcm_kcore[hr]); - printf(fmtcpu, p->pcm_cpu[hr]); - printf(fmtreal, p->pcm_real[hr]); - if(p->pcm_cpu[hr] == 0) p->pcm_cpu[hr] = 1; - printf(fmtmsz, p->pcm_kcore[hr]/p->pcm_cpu[hr]); - if(p->pcm_pc[hr] == 0) p->pcm_pc[hr] = 1; - printf(fmtmcpu, p->pcm_cpu[hr]/p->pcm_pc[hr]); - if (p->pcm_real[hr] == 0) - p->pcm_real[hr] = 1; - printf(fmthog, p->pcm_cpu[hr]/p->pcm_real[hr]); - printf(fmtcharx,p->pcm_io[hr]); - printf(fmtblkx,p->pcm_rw[hr]); - printf("\n"); -} - -void -pprint(struct pcms *p) -{ - printf(fmtcmd, p->pcm_comm); - printf(fmtcnt, p->pcm_pc[PRIME]); - printf(fmtcnt, p->pcm_pc[NONPRIME]); - printf(fmtkcore, TOTAL(p->pcm_kcore)); - printf(fmtcpu, p->pcm_cpu[PRIME]); - printf(fmtcpu, p->pcm_cpu[NONPRIME]); - printf(fmtreal, p->pcm_real[PRIME]); - printf(fmtreal, p->pcm_real[NONPRIME]); - if(TOTAL(p->pcm_cpu) == 0) p->pcm_cpu[PRIME] = 1; - printf(fmtmsz, TOTAL(p->pcm_kcore)/TOTAL(p->pcm_cpu)); - if(TOTAL(p->pcm_pc) == 0) p->pcm_pc[PRIME] = 1; - printf(fmtmcpu, TOTAL(p->pcm_cpu)/TOTAL(p->pcm_pc)); - if ( TOTAL(p->pcm_real) == 0) - p->pcm_real[PRIME] = 1; - printf(fmthog, TOTAL(p->pcm_cpu)/TOTAL(p->pcm_real)); - printf(fmtcharx,TOTAL(p->pcm_io)); - printf(fmtblkx, TOTAL(p->pcm_rw)); - printf("\n"); -} - -void -totprnt(struct pcms *p) -{ - printf(fmtcmd, p->pcm_comm); - printf(fmtcnt, TOTAL(p->pcm_pc)); - printf(fmtkcore, TOTAL(p->pcm_kcore)); - printf(fmtcpu, TOTAL(p->pcm_cpu)); - printf(fmtreal, TOTAL(p->pcm_real)); - if(TOTAL(p->pcm_cpu) == 0) p->pcm_cpu[PRIME] = 1; - printf(fmtmsz, TOTAL(p->pcm_kcore)/TOTAL(p->pcm_cpu)); - if(TOTAL(p->pcm_pc) == 0) p->pcm_pc[PRIME] = 1; - printf(fmtmcpu, TOTAL(p->pcm_cpu)/TOTAL(p->pcm_pc)); - if (TOTAL(p->pcm_real) == 0) - p->pcm_real[PRIME] = 1; - printf(fmthog, TOTAL(p->pcm_cpu)/TOTAL(p->pcm_real)); - printf(fmtcharx,TOTAL(p->pcm_io)); - printf(fmtblkx,TOTAL(p->pcm_rw)); - printf("\n"); -} - -void -outputc(void) -{ - int i; - - for (i = 0; i < csize; i++) - fwrite(&pcm[i], sizeof(pcm[i]), 1, stdout); -}
--- a/usr/src/cmd/acct/acctcom.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,722 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <time.h> -#include <string.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <grp.h> -#include <sys/acct.h> -#include <pwd.h> -#include <sys/stat.h> -#include <locale.h> -#include <stdlib.h> -#include <libgen.h> - -struct acct ab; -char command_name[16]; -char obuf[BUFSIZ]; -static char time_buf[50]; - -double cpucut, - syscut, - hogcut, - iocut, - realtot, - cputot, - usertot, - systot, - kcoretot, - iotot, - rwtot; -extern long timezone; -extern int daylight; /* daylight savings time if set */ -long daydiff, - offset = -2, - cmdcount; -ulong_t elapsed, - sys, - user, - cpu, - io, - rw, - mem, - etime; -time_t tstrt_b, - tstrt_a, - tend_b, - tend_a; -int backward, - flag_field, - average, - quiet, - option, - verbose = 1, - uidflag, - gidflag, - unkid, /*user doesn't have login on this machine*/ - errflg, - su_user, - fileout = 0, - stdinflg, - nfiles; -static int eflg = 0, - Eflg = 0, - sflg = 0, - Sflg = 0; -#ifdef uts -dev_t linedev = 0xffff; /* changed from -1, as dev_t is now ushort */ -#else -dev_t linedev = (dev_t)-1; -#endif -uid_t uidval; -gid_t gidval; -char *cname = NULL; /* command name pattern to match*/ - -struct passwd *getpwnam(), *getpwuid(), *pw; -struct group *getgrnam(),*grp; -long convtime(); - -#ifdef uts -float expand(); -#else -ulong_t expand(); -#endif - -char *ofile, - *devtolin(), - *uidtonam(); -dev_t lintodev(); - -void dofile(char *); -void doexit(int) __NORETURN; -void usage(void); -void fatal(char *, char *); -void println(void); -void printhd(void); -char *cmset(char *); - -FILE *ostrm; - -int -main(int argc, char **argv) -{ - int c; - - (void)setlocale(LC_ALL, ""); - setbuf(stdout,obuf); - while((c = getopt(argc, argv, - "C:E:H:I:O:S:abe:fg:hikl:mn:o:qrs:tu:v")) != EOF) { - switch(c) { - case 'C': - sscanf(optarg,"%lf",&cpucut); - continue; - case 'O': - sscanf(optarg,"%lf",&syscut); - continue; - case 'H': - sscanf(optarg,"%lf",&hogcut); - continue; - case 'I': - sscanf(optarg,"%lf",&iocut); - continue; - case 'a': - average++; - continue; - case 'b': - backward++; - continue; - case 'g': - if(sscanf(optarg,"%ld",&gidval) == 1) { - if (getgrgid(gidval) == NULL) - fatal("Unknown group", optarg); - } else if((grp=getgrnam(optarg)) == NULL) - fatal("Unknown group", optarg); - else - gidval=grp->gr_gid; - gidflag++; - continue; - case 'h': - option |= HOGFACTOR; - continue; - case 'i': - option |= IORW; - continue; - case 'k': - option |= KCOREMIN; - continue; - case 'm': - option |= MEANSIZE; - continue; - case 'n': - cname=cmset(optarg); - continue; - case 't': - option |= SEPTIME; - continue; - case 'r': - option |= CPUFACTOR; - continue; - case 'v': - verbose=0; - continue; - case 'l': - linedev = lintodev(optarg); - continue; - case 'u': - if(*optarg == '?') { - unkid++; - continue; - } - if(*optarg == '#') { - su_user++; - uidval = 0; - uidflag++; - continue; - } - if((pw = getpwnam(optarg)) == NULL) { - uidval = (uid_t)atoi(optarg); - /* atoi will return 0 in abnormal situation */ - if (uidval == 0 && strcmp(optarg, "0") != 0) { - fprintf(stderr, "%s: Unknown user %s\n", argv[0], optarg); - exit(1); - } - if ((pw = getpwuid(uidval)) == NULL) { - fprintf(stderr, "%s: Unknown user %s\n", argv[0], optarg); - exit(1); - } - uidflag++; - } else { - uidval = pw->pw_uid; - uidflag++; - } - continue; - case 'q': - quiet++; - verbose=0; - average++; - continue; - case 's': - sflg = 1; - tend_a = convtime(optarg); - continue; - case 'S': - Sflg = 1; - tstrt_a = convtime(optarg); - continue; - case 'f': - flag_field++; - continue; - case 'e': - eflg = 1; - tstrt_b = convtime(optarg); - continue; - case 'E': - Eflg = 1; - tend_b = convtime(optarg); - continue; - case 'o': - ofile = optarg; - fileout++; - if((ostrm = fopen(ofile, "w")) == NULL) { - perror("open error on output file"); - errflg++; - } - continue; - case '?': - errflg++; - continue; - } - } - - if(errflg) { - usage(); - exit(1); - } - - - argv = &argv[optind]; - while(optind++ < argc) { - dofile(*argv++); /* change from *argv */ - nfiles++; - } - - if(nfiles==0) { - if(isatty(0) || isdevnull()) - dofile(PACCT); - else { - stdinflg = 1; - backward = offset = 0; - dofile(NULL); - } - } - doexit(0); - /* NOTREACHED */ -} - -void -dofile(char *fname) -{ - struct acct *a = &ab; - struct tm *t; - time_t curtime; - time_t ts_a = 0, - ts_b = 0, - te_a = 0, - te_b = 0; - long daystart; - long nsize; - int ver; /* version of acct structure */ - int dst_secs; /* number of seconds to adjust - for daylight savings time */ - - if(fname != NULL) - if(freopen(fname, "r", stdin) == NULL) { - fprintf(stderr, "acctcom: cannot open %s\n", fname); - return; - } - - if (fread((char *)&ab, sizeof(struct acct), 1, stdin) != 1) - return; - else if (ab.ac_flag & AEXPND) - ver = 2; /* 4.0 acct structure */ - else - ver = 1; /* 3.x acct structure */ - - rewind(stdin); - - - if(backward) { - if (ver == 2) - nsize = sizeof(struct acct); /* make sure offset is signed */ - else - nsize = sizeof(struct o_acct); /* make sure offset is signed */ - fseek(stdin, (long)(-nsize), 2); - } - tzset(); - daydiff = a->ac_btime - (a->ac_btime % SECSINDAY); - time(&curtime); - t = localtime(&curtime); - if (daydiff < (curtime - (curtime % SECSINDAY))) { - time_t t; - /* - * it is older than today - */ - t = (time_t)a->ac_btime; - cftime(time_buf, DATE_FMT, &t); - fprintf(stdout, "\nACCOUNTING RECORDS FROM: %s", time_buf); - } - - /* adjust time by one hour for daylight savings time */ - if (daylight && t->tm_isdst != 0) - dst_secs = 3600; - else - dst_secs = 0; - daystart = (a->ac_btime - timezone + dst_secs) - - ((a->ac_btime - timezone + dst_secs) % SECSINDAY); - if (Sflg) { - ts_a = tstrt_a + daystart - dst_secs; - cftime(time_buf, DATE_FMT, &ts_a); - fprintf(stdout, "START AFT: %s", time_buf); - } - if (eflg) { - ts_b = tstrt_b + daystart - dst_secs; - cftime(time_buf, DATE_FMT, &ts_b); - fprintf(stdout, "START BEF: %s", time_buf); - } - if (sflg) { - te_a = tend_a + daystart - dst_secs; - cftime(time_buf, DATE_FMT, &te_a); - fprintf(stdout, "END AFTER: %s", time_buf); - } - if (Eflg) { - te_b = tend_b + daystart - dst_secs; - cftime(time_buf, DATE_FMT, &te_b); - fprintf(stdout, "END BEFOR: %s", time_buf); - } - if(ts_a) { - if (te_b && ts_a > te_b) te_b += SECSINDAY; - } - - while(aread(ver) != 0) { - elapsed = expand(a->ac_etime); - etime = (ulong_t)a->ac_btime + (ulong_t)SECS(elapsed); - if(ts_a || ts_b || te_a || te_b) { - - if(te_a && (etime < te_a)) { - if(backward) return; - else continue; - } - if(te_b && (etime > te_b)) { - if(backward) continue; - else return; - } - if(ts_a && (a->ac_btime < ts_a)) - continue; - if(ts_b && (a->ac_btime > ts_b)) - continue; - } - if(!MYKIND(a->ac_flag)) - continue; - if(su_user && !SU(a->ac_flag)) - continue; - sys = expand(a->ac_stime); - user = expand(a->ac_utime); - cpu = sys + user; - if(cpu == 0) - cpu = 1; - mem = expand(a->ac_mem); - (void) strncpy(command_name, a->ac_comm, 8); - io=expand(a->ac_io); - rw=expand(a->ac_rw); - if(cpucut && cpucut >= SECS(cpu)) - continue; - if(syscut && syscut >= SECS(sys)) - continue; -#ifdef uts - if(linedev != 0xffff && a->ac_tty != linedev) - continue; -#else - if(linedev != (dev_t)-1 && a->ac_tty != linedev) - continue; -#endif - if(uidflag && a->ac_uid != uidval) - continue; - if(gidflag && a->ac_gid != gidval) - continue; - if(cname && !cmatch(a->ac_comm,cname)) - continue; - if(iocut && iocut > io) - continue; - if(unkid && uidtonam(a->ac_uid)[0] != '?') - continue; - if(verbose && (fileout == 0)) { - printhd(); - verbose = 0; - } - if(elapsed == 0) - elapsed++; - if(hogcut && hogcut >= (double)cpu/(double)elapsed) - continue; - if(fileout) - fwrite(&ab, sizeof(ab), 1, ostrm); - else - println(); - if(average) { - cmdcount++; - realtot += (double)elapsed; - usertot += (double)user; - systot += (double)sys; - kcoretot += (double)mem; - iotot += (double)io; - rwtot += (double)rw; - }; - } -} - -int -aread(int ver) -{ - static int ok = 1; - struct o_acct oab; - int ret; - - if (ver != 2) { - if ((ret = fread((char *)&oab, sizeof(struct o_acct), 1, stdin)) == 1){ - /* copy SVR3 acct struct to SVR4 acct struct */ - ab.ac_flag = oab.ac_flag | AEXPND; - ab.ac_stat = oab.ac_stat; - ab.ac_uid = (uid_t) oab.ac_uid; - ab.ac_gid = (gid_t) oab.ac_gid; - ab.ac_tty = (dev_t) oab.ac_tty; - ab.ac_btime = oab.ac_btime; - ab.ac_utime = oab.ac_utime; - ab.ac_stime = oab.ac_stime; - ab.ac_mem = oab.ac_mem; - ab.ac_io = oab.ac_io; - ab.ac_rw = oab.ac_rw; - strcpy(ab.ac_comm, oab.ac_comm); - } - } else - ret = fread((char *)&ab, sizeof(struct acct), 1, stdin); - - - if(backward) { - if(ok) { - if(fseek(stdin, - (long)(offset*(ver == 2 ? sizeof(struct acct) : - sizeof(struct o_acct))), 1) != 0) { - - rewind(stdin); /* get 1st record */ - ok = 0; - } - } else - ret = 0; - } - return(ret != 1 ? 0 : 1); -} - -void -printhd(void) -{ - fprintf(stdout, "COMMAND START END REAL"); - ps("CPU"); - if(option & SEPTIME) - ps("(SECS)"); - if(option & IORW){ - ps("CHARS"); - ps("BLOCKS"); - } - if(option & CPUFACTOR) - ps("CPU"); - if(option & HOGFACTOR) - ps("HOG"); - if(!option || (option & MEANSIZE)) - ps("MEAN"); - if(option & KCOREMIN) - ps("KCORE"); - fprintf(stdout, "\n"); - fprintf(stdout, "NAME USER TTYNAME TIME TIME (SECS)"); - if(option & SEPTIME) { - ps("SYS"); - ps("USER"); - } else - ps("(SECS)"); - if(option & IORW) { - ps("TRNSFD"); - ps("READ"); - } - if(option & CPUFACTOR) - ps("FACTOR"); - if(option & HOGFACTOR) - ps("FACTOR"); - if(!option || (option & MEANSIZE)) - ps("SIZE(K)"); - if(option & KCOREMIN) - ps("MIN"); - if(flag_field) - fprintf(stdout, " F STAT"); - fprintf(stdout, "\n"); - fflush(stdout); -} - -void -println(void) -{ - char name[32]; - struct acct *a = &ab; - time_t t; - - if(quiet) - return; - if(!SU(a->ac_flag)) - strcpy(name,command_name); - else { - strcpy(name,"#"); - strcat(name,command_name); - } - fprintf(stdout, "%-*.*s", (OUTPUT_NSZ + 1), - (OUTPUT_NSZ + 1), name); - strcpy(name,uidtonam(a->ac_uid)); - if(*name != '?') - fprintf(stdout, " %-*.*s", (OUTPUT_NSZ + 1), - (OUTPUT_NSZ + 1), name); - else - fprintf(stdout, " %-9d",a->ac_uid); -#ifdef uts - fprintf(stdout, " %-*.*s", OUTPUT_LSZ, OUTPUT_LSZ, - a->ac_tty != 0xffff? devtolin(a->ac_tty):"?"); -#else - fprintf(stdout, " %-*.*s", OUTPUT_LSZ, OUTPUT_LSZ, - a->ac_tty != (dev_t)-1? devtolin(a->ac_tty):"?"); -#endif - t = a->ac_btime; - cftime(time_buf, DATE_FMT1, &t); - fprintf(stdout, "%.9s", time_buf); - cftime(time_buf, DATE_FMT1, (time_t *)&etime); - fprintf(stdout, "%.9s ", time_buf); - pf((double)SECS(elapsed)); - if(option & SEPTIME) { - pf((double)sys / HZ); - pf((double)user / HZ); - } else - pf((double)cpu / HZ); - if(option & IORW) - fprintf(stdout, io < 100000000 ? "%8ld%8ld" : "%12ld%8ld",io,rw); - if(option & CPUFACTOR) - pf((double)user / cpu); - if(option & HOGFACTOR) - pf((double)cpu / elapsed); - if(!option || (option & MEANSIZE)) - pf(KCORE(mem / cpu)); - if(option & KCOREMIN) - pf(MINT(KCORE(mem))); - if(flag_field) - fprintf(stdout, " %1o %3o", (unsigned char) a->ac_flag, - (unsigned char) a->ac_stat); - fprintf(stdout, "\n"); -} - -/* - * convtime converts time arg to internal value - * arg has form hr:min:sec, min or sec are assumed to be 0 if omitted - */ -long -convtime(str) -char *str; -{ - long hr, min, sec; - - min = sec = 0; - - if(sscanf(str, "%ld:%ld:%ld", &hr, &min, &sec) < 1) { - fatal("acctcom: bad time:", str); - } - tzset(); - sec += (min*60); - sec += (hr*3600); - return(sec + timezone); -} - -int -cmatch(char *comm, char *cstr) -{ - - char xcomm[9]; - int i; - - for(i=0;i<8;i++){ - if(comm[i]==' '||comm[i]=='\0') - break; - xcomm[i] = comm[i]; - } - xcomm[i] = '\0'; - - return (regex(cstr,xcomm) ? 1 : 0); -} - -char * -cmset(char *pattern) -{ - - if((pattern=(char *)regcmp(pattern,(char *)0))==NULL){ - fatal("pattern syntax", NULL); - } - - return (pattern); -} - -void -doexit(int status) -{ - if(!average) - exit(status); - if(cmdcount) { - fprintf(stdout, "cmds=%ld ",cmdcount); - fprintf(stdout, "Real=%-6.2f ",SECS(realtot)/cmdcount); - cputot = systot + usertot; - fprintf(stdout, "CPU=%-6.2f ",SECS(cputot)/cmdcount); - fprintf(stdout, "USER=%-6.2f ",SECS(usertot)/cmdcount); - fprintf(stdout, "SYS=%-6.2f ",SECS(systot)/cmdcount); - fprintf(stdout, "CHAR=%-8.2f ",iotot/cmdcount); - fprintf(stdout, "BLK=%-8.2f ",rwtot/cmdcount); - fprintf(stdout, "USR/TOT=%-4.2f ",usertot/cputot); - fprintf(stdout, "HOG=%-4.2f ",cputot/realtot); - fprintf(stdout, "\n"); - } - else - fprintf(stdout, "\nNo commands matched\n"); - exit(status); -} - -int -isdevnull(void) -{ - struct stat filearg; - struct stat devnull; - - if(fstat(0,&filearg) == -1) { - fprintf(stderr,"acctcom: cannot stat stdin\n"); - return (0); - } - if(stat("/dev/null",&devnull) == -1) { - fprintf(stderr,"acctcom: cannot stat /dev/null\n"); - return (0); - } - - if (filearg.st_rdev == devnull.st_rdev) - return (1); - else - return (0); -} - -void -fatal(char *s1, char *s2) -{ - fprintf(stderr,"acctcom: %s %s\n", s1, (s2 ? s2 : "")); - exit(1); -} - -void -usage(void) -{ - fprintf(stderr, "Usage: acctcom [options] [files]\n"); - fprintf(stderr, "\nWhere options can be:\n"); - diag("-b read backwards through file"); - diag("-f print the fork/exec flag and exit status"); - diag("-h print hog factor (total-CPU-time/elapsed-time)"); - diag("-i print I/O counts"); - diag("-k show total Kcore minutes instead of memory size"); - diag("-m show mean memory size"); - diag("-r show CPU factor (user-time/(sys-time + user-time))"); - diag("-t show separate system and user CPU times"); - diag("-v don't print column headings"); - diag("-a print average statistics of selected commands"); - diag("-q print average statistics only"); - diag("-l line \tshow processes belonging to terminal /dev/line"); - diag("-u user \tshow processes belonging to user name or user ID"); - diag("-u # \tshow processes executed by super-user"); - diag("-u ? \tshow processes executed by unknown UID's"); - diag("-g group show processes belonging to group name of group ID"); - diag("-s time \tshow processes ending after time (hh[:mm[:ss]])"); - diag("-e time \tshow processes starting before time"); - diag("-S time \tshow processes starting after time"); - diag("-E time \tshow processes ending before time"); - diag("-n regex select commands matching the ed(1) regular expression"); - diag("-o file \tdo not print, put selected pacct records into file"); - diag("-H factor show processes that exceed hog factor"); - diag("-O sec \tshow processes that exceed CPU system time sec"); - diag("-C sec \tshow processes that exceed total CPU time sec"); - diag("-I chars show processes that transfer more than char chars"); -}
--- a/usr/src/cmd/acct/acctcon.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,514 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * acctcon [-l file] [-o file] <wtmpx-file - * -l file causes output of line usage summary - * -o file causes first/last/reboots report to be written to file - * reads input (normally /var/log/wtmpx), produces - * list of sessions, sorted by ending time in tacct.h format - */ - -#include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <ctype.h> -#include <time.h> -#include <utmpx.h> -#include <locale.h> -#include <string.h> -#include <search.h> -#include <stdlib.h> - -int a_tsize = A_TSIZE; -int tsize = -1; /* highest index of used slot in tbuf table */ -static int csize; -struct utmpx wb; /* record structure read into */ -struct ctmp cb; /* record structure written out of */ -struct tacct tb; -double timet, timei; - -struct tbuf { - char tline[LSZ]; /* /dev/... */ - char tname[NSZ]; /* user name */ - time_t ttime; /* start time */ - dev_t tdev; /* device */ - int tlsess; /* # complete sessions */ - int tlon; /* # times on (ut_type of 7) */ - int tloff; /* # times off (ut_type != 7) */ - long ttotal; /* total time used on this line */ -} *tbuf; - -struct ctab { - uid_t ct_uid; - char ct_name[NSZ]; - long ct_con[2]; - ushort_t ct_sess; -} *pctab; - -int nsys; -struct sys { - char sname[LSZ]; /* reasons for ACCOUNTING records */ - char snum; /* number of times encountered */ -} sy[NSYS]; - -static char time_buf[50]; -time_t datetime; /* old time if date changed, otherwise 0 */ -time_t firstime; -time_t lastime; -int ndates; /* number of times date changed */ -int exitcode; -char *report = NULL; -char *replin = NULL; - -uid_t namtouid(); -dev_t lintodev(); -static int valid(void); -static void fixup(FILE *); -static void loop(void); -static void bootshut(void); -static int iline(void); -static void upall(void); -static void update(struct tbuf *); -static void printrep(void); -static void printlin(void); -static int tcmp(struct tbuf *, struct tbuf *); -static int node_compare(const void *, const void *); -static void enter(struct ctmp *); -static void print_node(const void *, VISIT, int); -static void output(void); - -extern char *optarg; -extern int optind; - -void **root = NULL; - -int -main(int argc, char **argv) -{ - int c; - - (void) setlocale(LC_ALL, ""); - while ((c = getopt(argc, argv, "l:o:")) != EOF) - switch (c) { - case 'l': - replin = optarg; - break; - case 'o': - report = optarg; - break; - case '?': - fprintf(stderr, "usage: %s [-l lineuse] " - "[-o reboot]\n", argv[0]); - exit(1); - } - - if ((tbuf = (struct tbuf *)calloc(a_tsize, - sizeof (struct tbuf))) == NULL) { - fprintf(stderr, "acctcon: Cannot allocate memory\n"); - exit(3); - } - - /* - * XXX - fixme - need a good way of getting the fd that getutxent would - * use to access wtmpx, so we can convert this read of stdin to use - * the APIs and remove the dependence on the existence of the file. - */ - while (fread(&wb, sizeof (wb), 1, stdin) == 1) { - if (firstime == 0) - firstime = wb.ut_xtime; - if (valid()) - loop(); - else - fixup(stderr); - } - wb.ut_name[0] = '\0'; - strcpy(wb.ut_line, "acctcon"); - wb.ut_type = ACCOUNTING; - wb.ut_xtime = lastime; - loop(); - - output(); - - if (report != NULL) - printrep(); - if (replin != NULL) - printlin(); - - exit(exitcode); -} - - -/* - * valid: check input wtmpx record, return 1 if looks OK - */ -static int -valid() -{ - int i, c; - - /* XPG say that user names should not start with a "-" */ - if ((c = wb.ut_name[0]) == '-') - return (0); - - for (i = 0; i < NSZ; i++) { - c = wb.ut_name[i]; - if (isalnum(c) || c == '$' || c == ' ' || c == '.' || - c == '_' || c == '-') - continue; - else if (c == '\0') - break; - else - return (0); - } - - if ((wb.ut_type >= EMPTY) && (wb.ut_type <= UTMAXTYPE)) - return (1); - - return (0); -} - -static void -fixup(FILE *stream) -{ - fprintf(stream, "bad wtmpx: offset %lu.\n", ftell(stdin)-sizeof (wb)); - fprintf(stream, "bad record is: %.*s\t%.*s\t%lu", - sizeof (wb.ut_line), - wb.ut_line, - sizeof (wb.ut_name), - wb.ut_name, - wb.ut_xtime); - cftime(time_buf, DATE_FMT, &wb.ut_xtime); - fprintf(stream, "\t%s", time_buf); - exitcode = 1; -} - -static void -loop() -{ - int timediff; - struct tbuf *tp; - - if (wb.ut_line[0] == '\0') /* It's an init admin process */ - return; /* no connect accounting data here */ - switch (wb.ut_type) { - case OLD_TIME: - datetime = wb.ut_xtime; - return; - case NEW_TIME: - if (datetime == 0) - return; - timediff = wb.ut_xtime - datetime; - for (tp = tbuf; tp <= &tbuf[tsize]; tp++) - tp->ttime += timediff; - datetime = 0; - ndates++; - return; - case DOWN_TIME: - return; - case BOOT_TIME: - upall(); - /* FALLTHROUGH */ - case ACCOUNTING: - case RUN_LVL: - lastime = wb.ut_xtime; - bootshut(); - return; - case USER_PROCESS: - case LOGIN_PROCESS: - case INIT_PROCESS: - case DEAD_PROCESS: /* WHCC mod 3/86 */ - update(&tbuf[iline()]); - return; - case EMPTY: - return; - default: - cftime(time_buf, DATE_FMT, &wb.ut_xtime); - fprintf(stderr, "acctcon: invalid type %d for %s %s %s", - wb.ut_type, - wb.ut_name, - wb.ut_line, - time_buf); - } -} - -/* - * bootshut: record reboot (or shutdown) - * bump count, looking up wb.ut_line in sy table - */ -static void -bootshut() -{ - int i; - - for (i = 0; i < nsys && !EQN(wb.ut_line, sy[i].sname); i++) - ; - if (i >= nsys) { - if (++nsys > NSYS) { - fprintf(stderr, - "acctcon: recompile with larger NSYS\n"); - nsys = NSYS; - return; - } - CPYN(sy[i].sname, wb.ut_line); - } - sy[i].snum++; -} - -/* - * iline: look up/enter current line name in tbuf, return index - * (used to avoid system dependencies on naming) - */ -static int -iline() -{ - int i; - - for (i = 0; i <= tsize; i++) - if (EQN(wb.ut_line, tbuf[i].tline)) - return (i); - if (++tsize >= a_tsize) { - a_tsize = a_tsize + A_TSIZE; - if ((tbuf = reallocarray(tbuf, a_tsize, - sizeof (struct tbuf))) == NULL) { - fprintf(stderr, "acctcon: Cannot reallocate memory\n"); - exit(2); - } - } - - CPYN(tbuf[tsize].tline, wb.ut_line); - tbuf[tsize].tdev = lintodev(wb.ut_line); - return (tsize); -} - -static void -upall() -{ - struct tbuf *tp; - - wb.ut_type = DEAD_PROCESS; /* fudge a logoff for reboot record. */ - for (tp = tbuf; tp <= &tbuf[tsize]; tp++) - update(tp); -} - -/* - * update tbuf with new time, write ctmp record for end of session - */ -static void -update(struct tbuf *tp) -{ - time_t told, /* last time for tbuf record */ - tnew; /* time of this record */ - /* Difference is connect time */ - - told = tp->ttime; - tnew = wb.ut_xtime; - if (told > tnew) { - cftime(time_buf, DATE_FMT, &told); - fprintf(stderr, "acctcon: bad times: old: %s", time_buf); - cftime(time_buf, DATE_FMT, &tnew); - fprintf(stderr, "new: %s", time_buf); - exitcode = 1; - tp->ttime = tnew; - return; - } - tp->ttime = tnew; - switch (wb.ut_type) { - case USER_PROCESS: - tp->tlsess++; - /* - * Someone logged in without logging off. Put out record. - */ - if (tp->tname[0] != '\0') { - cb.ct_tty = tp->tdev; - CPYN(cb.ct_name, tp->tname); - cb.ct_uid = namtouid(cb.ct_name); - cb.ct_start = told; - if (pnpsplit(cb.ct_start, (ulong_t)(tnew-told), - cb.ct_con) == 0) { - fprintf(stderr, "acctcon: could not calculate " - "prime/non-prime hours\n"); - exit(1); - } - enter(&cb); - tp->ttotal += tnew-told; - } else /* Someone just logged in */ - tp->tlon++; - CPYN(tp->tname, wb.ut_name); - break; - case DEAD_PROCESS: - tp->tloff++; - if (tp->tname[0] != '\0') { /* Someone logged off */ - /* Set up and print ctmp record */ - cb.ct_tty = tp->tdev; - CPYN(cb.ct_name, tp->tname); - cb.ct_uid = namtouid(cb.ct_name); - cb.ct_start = told; - if (pnpsplit(cb.ct_start, (ulong_t)(tnew-told), - cb.ct_con) == 0) { - fprintf(stderr, "acctcon: could not calculate " - "prime/non-prime hours\n"); - exit(1); - } - enter(&cb); - tp->ttotal += tnew-told; - tp->tname[0] = '\0'; - } - } -} - -static void -printrep() -{ - int i; - - freopen(report, "w", stdout); - cftime(time_buf, DATE_FMT, &firstime); - printf("from %s", time_buf); - cftime(time_buf, DATE_FMT, &lastime); - printf("to %s", time_buf); - if (ndates) - printf("%d\tdate change%c\n", ndates, (ndates > 1 ? 's' : - '\0')); - for (i = 0; i < nsys; i++) - printf("%d\t%.*s\n", sy[i].snum, - sizeof (sy[i].sname), sy[i].sname); -} - - -/* - * print summary of line usage - * accuracy only guaranteed for wtmpx file started fresh - */ -static void -printlin() -{ - struct tbuf *tp; - double ttime; - int tsess, ton, toff; - - freopen(replin, "w", stdout); - ttime = 0.0; - tsess = ton = toff = 0; - timet = MINS(lastime-firstime); - printf("TOTAL DURATION IS %.0f MINUTES\n", timet); - printf("LINE MINUTES PERCENT # SESS # ON # OFF\n"); - qsort((char *)tbuf, tsize + 1, sizeof (tbuf[0]), - (int (*)(const void *, const void *))tcmp); - for (tp = tbuf; tp <= &tbuf[tsize]; tp++) { - timei = MINS(tp->ttotal); - ttime += timei; - tsess += tp->tlsess; - ton += tp->tlon; - toff += tp->tloff; - printf("%-*.*s %-7.0f %-7.0f %-6d %-4d %-5d\n", - OUTPUT_LSZ, - OUTPUT_LSZ, - tp->tline, - timei, - (timet > 0.)? 100*timei/timet : 0., - tp->tlsess, - tp->tlon, - tp->tloff); - } - printf("TOTALS %-7.0f -- %-6d %-4d %-5d\n", - ttime, tsess, ton, toff); -} - -static int -tcmp(struct tbuf *t1, struct tbuf *t2) -{ - return (strncmp(t1->tline, t2->tline, LSZ)); -} - -static int -node_compare(const void *node1, const void *node2) -{ - if (((const struct ctab *)node1)->ct_uid > - ((const struct ctab *)node2)->ct_uid) - return (1); - else if (((const struct ctab *)node1)->ct_uid < - ((const struct ctab *)node2)->ct_uid) - return (-1); - else - return (0); -} - -static void -enter(struct ctmp *c) -{ - unsigned i; - int j; - struct ctab **pt; - - if ((pctab = (struct ctab *)malloc(sizeof (struct ctab))) == NULL) { - fprintf(stderr, "acctcon: malloc fail!\n"); - exit(2); - } - - pctab->ct_uid = c->ct_uid; - CPYN(pctab->ct_name, c->ct_name); - pctab->ct_con[0] = c->ct_con[0]; - pctab->ct_con[1] = c->ct_con[1]; - pctab->ct_sess = 1; - - if (*(pt = (struct ctab **)tsearch((void *)pctab, (void **)&root, \ - node_compare)) == NULL) { - fprintf(stderr, "Not enough space available to build tree\n"); - exit(1); - } - - if (*pt != pctab) { - (*pt)->ct_con[0] += c->ct_con[0]; - (*pt)->ct_con[1] += c->ct_con[1]; - (*pt)->ct_sess++; - free(pctab); - } - -} - -static void -print_node(const void *node, VISIT order, int level) -{ - if (order == postorder || order == leaf) { - tb.ta_uid = (*(struct ctab **)node)->ct_uid; - CPYN(tb.ta_name, (*(struct ctab **)node)->ct_name); - tb.ta_con[0] = ((*(struct ctab **)node)->ct_con[0]) / 60.0; - tb.ta_con[1] = ((*(struct ctab **)node)->ct_con[1]) / 60.0; - tb.ta_sc = (*(struct ctab **)node)->ct_sess; - fwrite(&tb, sizeof (tb), 1, stdout); - } -} - -static void -output() -{ - twalk((struct ctab *)root, print_node); -}
--- a/usr/src/cmd/acct/acctcon1.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,484 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * acctcon1 [-p] [-t] [-l file] [-o file] <wtmpx-file >ctmp-file - * -p print input only, no processing - * -t test mode: use latest time found in input, rather than - * current time when computing times of lines still on - * (only way to get repeatable data from old files) - * -l file causes output of line usage summary - * -o file causes first/last/reboots report to be written to file - * reads input (normally /var/log/wtmpx), produces - * list of sessions, sorted by ending time in ctmp.h/ascii format - * A_TSIZE is max # distinct ttys - */ - -#include <sys/types.h> -#include "acctdef.h" -#include <stdio.h> -#include <ctype.h> -#include <time.h> -#include <utmpx.h> -#include <locale.h> -#include <stdlib.h> - -int a_tsize = A_TSIZE; -int tsize = -1; /* used slots in tbuf table */ -struct utmpx wb; /* record structure read into */ -struct ctmp cb; /* record structure written out of */ - -struct tbuf { - char tline[LSZ]; /* /dev/... */ - char tname[NSZ]; /* user name */ - time_t ttime; /* start time */ - dev_t tdev; /* device */ - int tlsess; /* # complete sessions */ - int tlon; /* # times on (ut_type of 7) */ - int tloff; /* # times off (ut_type != 7) */ - long ttotal; /* total time used on this line */ -} * tbuf; - -#define DATE_FMT "%a %b %e %H:%M:%S %Y\n" -int nsys; -struct sys { - char sname[LSZ]; /* reasons for ACCOUNTING records */ - char snum; /* number of times encountered */ -} sy[NSYS]; - -time_t datetime; /* old time if date changed, otherwise 0 */ -time_t firstime; -time_t lastime; -int ndates; /* number of times date changed */ -int exitcode; -char *report = NULL; -char *replin = NULL; -int printonly; -int tflag; - -static char time_buf[50]; -uid_t namtouid(); -dev_t lintodev(); -static size_t wread(void); -static int valid(void); -static void fixup(FILE *); -static void loop(void); -static void bootshut(void); -static int iline(void); -static void upall(void); -static void update(struct tbuf *); -static void printrep(void); -static void printlin(void); -static void prctmp(struct ctmp *); - -int -main(int argc, char **argv) -{ - char *prog = argv[0]; - - (void)setlocale(LC_ALL, ""); - while (--argc > 0 && **++argv == '-') - switch(*++*argv) { - case 'l': - if (--argc > 0) - replin = *++argv; - continue; - case 'o': - if (--argc > 0) - report = *++argv; - continue; - case 'p': - printonly++; - continue; - case 't': - tflag++; - continue; - default: - fprintf(stderr, "usage: %s [-p] [-t] [-l lineuse] [-o reboot]\n", prog); - exit(1); - - } - - if ((tbuf = (struct tbuf *) calloc(a_tsize, - sizeof (struct tbuf))) == NULL) { - fprintf(stderr, "acctcon1: Cannot allocate memory\n"); - exit(3); - } - - if (printonly) { - while (wread()) { - if (valid()) { - printf("%.*s\t%.*s\t%lu", - sizeof (wb.ut_line), - wb.ut_line, - sizeof (wb.ut_name), - wb.ut_name, - wb.ut_xtime); - cftime(time_buf, DATE_FMT, &wb.ut_xtime); - printf("\t%s", time_buf); - } else - fixup(stdout); - - } - exit(exitcode); - } - - while (wread()) { - if (firstime == 0) - firstime = wb.ut_xtime; - if (valid()) - loop(); - else - fixup(stderr); - } - wb.ut_name[0] = '\0'; - strcpy(wb.ut_line, "acctcon1"); - wb.ut_type = ACCOUNTING; - if (tflag) - wb.ut_xtime = lastime; - else - time(&wb.ut_xtime); - loop(); - if (report != NULL) - printrep(); - if (replin != NULL) - printlin(); - exit(exitcode); -} - -static size_t -wread() -{ - return (fread(&wb, sizeof(wb), 1, stdin) == 1); - -} - -/* - * valid: check input wtmp record, return 1 if looks OK - */ -static int -valid() -{ - int i, c; - - /* XPG say that user names should not start with a "-". */ - if ((c = wb.ut_name[0]) == '-') - return(0); - - for (i = 0; i < NSZ; i++) { - c = wb.ut_name[i]; - if (isalnum(c) || c == '$' || c == ' ' || c == '_' || c == '-') - continue; - else if (c == '\0') - break; - else - return(0); - } - - if((wb.ut_type >= EMPTY) && (wb.ut_type <= UTMAXTYPE)) - return(1); - - return(0); -} - -/* - * fixup assumes that V6 wtmp (16 bytes long) is mixed in with - * V7 records (20 bytes each) - * - * Starting with Release 5.0 of UNIX, this routine will no - * longer reset the read pointer. This has a snowball effect - * On the following records until the offset corrects itself. - * If a message is printed from here, it should be regarded as - * a bad record and not as a V6 record. - */ -static void -fixup(FILE *stream) -{ - fprintf(stream, "bad wtmpx: offset %lu.\n", ftell(stdin)-sizeof(wb)); - fprintf(stream, "bad record is: %.*s\t%.*s\t%lu", - sizeof (wb.ut_line), - wb.ut_line, - sizeof (wb.ut_name), - wb.ut_name, - wb.ut_xtime); - cftime(time_buf, DATE_FMT, &wb.ut_xtime); - fprintf(stream, "\t%s", time_buf); -#ifdef V6 - fseek(stdin, (long)-4, 1); -#endif - exitcode = 1; -} - -static void -loop() -{ - int timediff; - struct tbuf *tp; - - if(wb.ut_line[0] == '\0' ) /* It's an init admin process */ - return; /* no connect accounting data here */ - switch(wb.ut_type) { - case OLD_TIME: - datetime = wb.ut_xtime; - return; - case NEW_TIME: - if(datetime == 0) - return; - timediff = wb.ut_xtime - datetime; - for (tp = tbuf; tp <= &tbuf[tsize]; tp++) - tp->ttime += timediff; - datetime = 0; - ndates++; - return; - case BOOT_TIME: - upall(); - /* FALLTHROUGH */ - case ACCOUNTING: - case RUN_LVL: - lastime = wb.ut_xtime; - bootshut(); - return; - case USER_PROCESS: - case LOGIN_PROCESS: - case INIT_PROCESS: - case DEAD_PROCESS: - update(&tbuf[iline()]); - return; - case EMPTY: - return; - default: - cftime(time_buf, DATE_FMT, &wb.ut_xtime); - fprintf(stderr, "acctcon1: invalid type %d for %s %s %s", - wb.ut_type, - wb.ut_name, - wb.ut_line, - time_buf); - } -} - -/* - * bootshut: record reboot (or shutdown) - * bump count, looking up wb.ut_line in sy table - */ -static void -bootshut() -{ - int i; - - for (i = 0; i < nsys && !EQN(wb.ut_line, sy[i].sname); i++) - ; - if (i >= nsys) { - if (++nsys > NSYS) { - fprintf(stderr, - "acctcon1: recompile with larger NSYS\n"); - nsys = NSYS; - return; - } - CPYN(sy[i].sname, wb.ut_line); - } - sy[i].snum++; -} - -/* - * iline: look up/enter current line name in tbuf, return index - * (used to avoid system dependencies on naming) - */ -static int -iline() -{ - int i; - - for (i = 0; i <= tsize; i++) - if (EQN(wb.ut_line, tbuf[i].tline)) - return(i); - if (++tsize >= a_tsize) { - a_tsize = a_tsize + A_TSIZE; - if ((tbuf = reallocarray(tbuf, a_tsize, - sizeof (struct tbuf))) == NULL) { - fprintf(stderr, "acctcon1: Cannot reallocate memory\n"); - exit(2); - } - } - - CPYN(tbuf[tsize].tline, wb.ut_line); - tbuf[tsize].tdev = lintodev(wb.ut_line); - return(tsize); -} - -static void -upall() -{ - struct tbuf *tp; - - wb.ut_type = INIT_PROCESS; /* fudge a logoff for reboot record */ - for (tp = tbuf; tp <= &tbuf[tsize]; tp++) - update(tp); -} - -/* - * update tbuf with new time, write ctmp record for end of session - */ -static void -update(struct tbuf *tp) -{ - time_t told, /* last time for tbuf record */ - tnew; /* time of this record */ - /* Difference is connect time */ - - told = tp->ttime; - tnew = wb.ut_xtime; - cftime(time_buf, DATE_FMT, &told); - fprintf(stderr, "The old time is: %s", time_buf); - cftime(time_buf, DATE_FMT, &tnew); - fprintf(stderr, "the new time is: %s", time_buf); - if (told > tnew) { - cftime(time_buf, DATE_FMT, &told); - fprintf(stderr, "acctcon1: bad times: old: %s", time_buf); - cftime(time_buf, DATE_FMT, &tnew); - fprintf(stderr, "new: %s", time_buf); - exitcode = 1; - tp->ttime = tnew; - return; - } - tp->ttime = tnew; - switch(wb.ut_type) { - case USER_PROCESS: - tp->tlsess++; - if(tp->tname[0] != '\0') { /* Someone logged in without */ - /* logging off. Put out record. */ - cb.ct_tty = tp->tdev; - CPYN(cb.ct_name, tp->tname); - cb.ct_uid = namtouid(cb.ct_name); - cb.ct_start = told; - if (pnpsplit(cb.ct_start, (ulong_t)(tnew-told), - cb.ct_con) == 0) { - fprintf(stderr, "acctcon1: could not calculate prime/non-prime hours\n"); - - exit(1); - } - prctmp(&cb); - tp->ttotal += tnew-told; - } - else /* Someone just logged in */ - tp->tlon++; - CPYN(tp->tname, wb.ut_name); - break; - case INIT_PROCESS: - case LOGIN_PROCESS: - case DEAD_PROCESS: - tp->tloff++; - if(tp->tname[0] != '\0') { /* Someone logged off */ - /* Set up and print ctmp record */ - cb.ct_tty = tp->tdev; - CPYN(cb.ct_name, tp->tname); - cb.ct_uid = namtouid(cb.ct_name); - cb.ct_start = told; - if (pnpsplit(cb.ct_start, (ulong_t)(tnew-told), - cb.ct_con) == 0) { - fprintf(stderr, "acctcon1: could not calculate prime/non-prime hours\n"); - exit(1); - } - prctmp(&cb); - tp->ttotal += tnew-told; - tp->tname[0] = '\0'; - } - } -} - -static void -printrep() -{ - int i; - - freopen(report, "w", stdout); - cftime(time_buf, DATE_FMT, &firstime); - printf("from %s", time_buf); - cftime(time_buf, DATE_FMT, &lastime); - printf("to %s", time_buf); - if (ndates) - printf("%d\tdate change%c\n",ndates,(ndates>1 ? 's' : '\0')); - for (i = 0; i < nsys; i++) - printf("%d\t%.*s\n", sy[i].snum, - sizeof (sy[i].sname), sy[i].sname); -} - -/* - * print summary of line usage - * accuracy only guaranteed for wtmpx file started fresh - */ -static void -printlin() -{ - struct tbuf *tp; - double timet, timei; - double ttime; - int tsess, ton, toff; - - freopen(replin, "w", stdout); - ttime = 0.0; - tsess = ton = toff = 0; - timet = MINS(lastime-firstime); - printf("TOTAL DURATION IS %.0f MINUTES\n", timet); - printf("LINE MINUTES PERCENT # SESS # ON # OFF\n"); - for (tp = tbuf; tp <= &tbuf[tsize]; tp++) { - timei = MINS(tp->ttotal); - ttime += timei; - tsess += tp->tlsess; - ton += tp->tlon; - toff += tp->tloff; - printf("%-*.*s %-7.0f %-7.0f %-6d %-4d %-5d\n", - OUTPUT_LSZ, - OUTPUT_LSZ, - tp->tline, - timei, - (timet > 0.)? 100*timei/timet : 0., - tp->tlsess, - tp->tlon, - tp->tloff); - } - printf("TOTALS %-7.0f -- %-6d %-4d %-5d\n", - ttime, tsess, ton, toff); -} - -static void -prctmp(struct ctmp *t) -{ - - printf("%u\t%ld\t%.*s\t%lu\t%lu\t%lu", - t->ct_tty, - t->ct_uid, - OUTPUT_NSZ, - t->ct_name, - t->ct_con[0], - t->ct_con[1], - t->ct_start); - cftime(time_buf, DATE_FMT, &t->ct_start); - printf("\t%s", time_buf); -}
--- a/usr/src/cmd/acct/acctcon2.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#pragma ident "%Z%%M% %I% %E% SMI" -/* - * acctcon2 <ctmp >ctacct - * reads std. input (ctmp.h/ascii format) - * converts to tacct.h form, writes to std. output - */ - -#include <sys/types.h> -#include "acctdef.h" -#include <stdio.h> -#include <stdlib.h> - -struct ctmp cb; -struct tacct tb; - -int -main(int argc, char **argv) -{ - tb.ta_sc = 1; - while (scanf("%lu\t%ld\t%s\t%lu\t%lu\t%lu\t%*[^\n]", - &cb.ct_tty, - &cb.ct_uid, - cb.ct_name, - &cb.ct_con[0], - &cb.ct_con[1], - &cb.ct_start) != EOF) { - - tb.ta_uid = cb.ct_uid; - CPYN(tb.ta_name, cb.ct_name); - tb.ta_con[0] = MINS(cb.ct_con[0]); - tb.ta_con[1] = MINS(cb.ct_con[1]); - fwrite(&tb, sizeof (tb), 1, stdout); - } - exit(0); -}
--- a/usr/src/cmd/acct/acctdef.h Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <utmpx.h> - -static struct utmpx utdummy; /* dummy - used to get member sizes */ - -#define PACCT "/var/log/pacct" -#define HOLFILE "/etc/acct/holidays" -#define NHOLIDAYS 200 /* max number of company holidays per year */ -#define NSYS 200 /* number of run state changes */ -#define NFILE 100 /* max number of files that acctmerg handles */ - -#ifdef uts -#define CSIZE 10001 -#define MAXUSERS 5003 -#define A_SSIZE 60001 /* max num of sessions in 1 acct run */ -#define A_TSIZE 10001 /* max num of line names in 1 acct run */ -#define A_USIZE 20001 /* max num of distinct login names in 1 acct run */ -#else -#define CSIZE 5001 -#define MAXUSERS 3001 -#define A_SSIZE 6001 /* max num of sessions in 1 acct run */ -#define A_TSIZE 1001 /* max num of line names in 1 acct run */ -#define A_USIZE 2001 /* max num of distinct login names in 1 acct run */ -#endif -#define TSIZE1 100 /* # distinct names, for speed only */ -#define USIZE1 100 - -#define MAXIGN 10 -#define UNUSED -1 -#define FAIL -1 -#define SUCCEED 0 -#define TRUE 1 -#define FALSE 0 -#define PRIME 0 -#define NONPRIME 1 -#define MEANSIZE 01 -#define KCOREMIN 02 -#define HOGFACTOR 04 -#define SEPTIME 010 -#define CPUFACTOR 020 -#define IORW 040 -#define ROOT 0 -#define ERR (-1) -#define OK 0 -#define NOGOOD 1 -#define VALID 0 -#define INVALID 1 -/* - * The size of LSZ is based on MAX_SRCH_DEPTH because of the - * implementation of devtolin() - */ -#define MAX_SRCH_DEPTH 4 -#define LSZ (MAX_SRCH_DEPTH * sizeof (utdummy.ut_line)) -#define MAX_DEV_PATH (LSZ + 5) /* max len of abs line name path */ -#define NSZ (sizeof (utdummy.ut_name)) /* sizeof login name */ -#define LINESZ (sizeof (utdummy.ut_line)) /* sizeof device name */ -/* - * These exist for backward compatibility. Until we can change the - * output formats, we need to keep the field widths the same as - * they always have been. - */ -#define OUTPUT_NSZ 8 -#define OUTPUT_LSZ 12 - -#define MYKIND(flag) ((flag & ACCTF) == 0) -#define SU(flag) ((flag & ASU) == ASU) -#define TOTAL(a) (a[PRIME] + a[NONPRIME]) -#define okay(time) ((time/100>=0) && (time/100<=24) \ - && (time%100>=0) && (time%100<60)) -#define pf(dble) fprintf(stdout, " %7.2lf", dble) -#define ps(s) fprintf(stdout, "%8.8s", s) -#define diag(string) fprintf(stderr, "\t%s\n", string) -#define DATE_FMT "%a %b %e %H:%M:%S %Y\n" -#define DATE_FMT1 " %H:%M:%S" -#define CBEMPTY (ctab[i].ct_sess == 0) -#define UBEMPTY (ub[i].ut_pc == 0 && ub[i].ut_cpu[0] == 0 && \ -ub[i].ut_cpu[1] == 0 && ub[i].ut_kcore[0] ==0 && ub[i].ut_kcore[1] == 0) - - -#define EQN(s1, s2) (strncmp(s1, s2, sizeof(s1)) == 0) -#define CPYN(s1, s2) (void) strncpy(s1, s2 ? s2 : "", sizeof(s1)) - -#define SECSINDAY 86400L -#define SECS(tics) ((double) tics)/HZ -#define MINS(secs) ((double) secs)/60 -#define MINT(tics) ((double) tics)/(60*HZ) - -#include <unistd.h> -#if UTS -#define KCORE(clicks) ((double) BSIZE * (clicks/1024.0)) -#else -#define KCORE(clicks) ((double) (sysconf(_SC_PAGESIZE) >> 10) *clicks) -#endif - -/* - * total accounting (for acct period), also for day - */ - -struct tacct { - uid_t ta_uid; /* userid */ - char ta_name[NSZ]; /* login name */ - float ta_cpu[2]; /* cum. cpu time, p/np (mins) */ - float ta_kcore[2]; /* cum kcore-minutes, p/np */ - float ta_con[2]; /* cum. connect time, p/np, mins */ - float ta_du; /* cum. disk usage */ - long ta_pc; /* count of processes */ - unsigned short ta_sc; /* count of login sessions */ - unsigned short ta_dc; /* count of disk samples */ - unsigned short ta_fee; /* fee for special services */ -}; - - -/* - * connect time record - */ -struct ctmp { - dev_t ct_tty; /* major minor */ - uid_t ct_uid; /* userid */ - char ct_name[NSZ]; /* login name */ - long ct_con[2]; /* connect time (p/np) secs */ - time_t ct_start; /* session start time */ -}; - -/* - * per process temporary data - */ -struct ptmp { - uid_t pt_uid; /* userid */ - char pt_name[NSZ]; /* login name */ - ulong_t pt_cpu[2]; /* CPU (sys+usr) P/NP time tics */ - unsigned pt_mem; /* avg. memory size (64byte clicks) */ -};
--- a/usr/src/cmd/acct/acctdisk.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#pragma ident "%Z%%M% %I% %E% SMI" -/* - * acctdisk <dtmp >dtacct - * reads std.input & converts to tacct.h format, writes to output - * input: - * uid name #blocks - */ - -#include <sys/types.h> -#include "acctdef.h" -#include <stdio.h> -#include <stdlib.h> - -struct tacct tb; -char ntmp[NSZ+1]; - -int -main(int argc, char **argv) -{ - int rc; - - tb.ta_dc = 1; - while ((rc = scanf("%ld\t%s\t%f", - &tb.ta_uid, - ntmp, - &tb.ta_du)) == 3) { - - CPYN(tb.ta_name, ntmp); - fwrite(&tb, sizeof (tb), 1, stdout); - } - - if (rc != EOF) { - fprintf(stderr, "\nacctdisk: incorrect input format.\n"); - exit(1); - } else { - exit(0); - } -}
--- a/usr/src/cmd/acct/acctdusg.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,282 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8 */ -/* - * acctdusg [-u file] [-p file] > dtmp-file - * -u file for names of files not charged to anyone - * -p get password info from file - * reads std input (normally from find / -print) - * and computes disk resource consumption by login - */ -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <pwd.h> -#include <stdlib.h> -#include <string.h> -#include <limits.h> -#include <libcmdutils.h> - -#include "acctdef.h" - -struct disk { - struct disk *next; /* next entry at same hash tbl index */ - uid_t dsk_uid; /* user id of login name */ - blkcnt_t dsk_du; /* disk usage */ - char dsk_name[NSZ+1]; /* login name */ - char validuser; /* set if the uid exists */ -}; - -static char *pfile = NULL; -static FILE *nchrg = NULL; -static avl_tree_t *tree = NULL; - -static struct disk *usglist[MAXUSERS]; /* holds data on disk usg by uid */ -#define HASHKEY(x) ((int)((unsigned int)(x) % MAXUSERS)) - -static struct disk *hash_insert(uid_t); -static struct disk *hash_find(uid_t); -static void openerr(char *); -static void output(void); -static void validate_entry(struct disk *, struct passwd *); -static void charge(char *); -#ifdef DEBUG -static void pdisk(void); -#endif -struct passwd *fgetpwent(FILE *); - -int -main(int argc, char **argv) -{ - char fbuf[PATH_MAX+1], *fb; - FILE *pwf; - int c; - struct passwd *pw; - struct disk *entry; - - while ((c = getopt(argc, argv, "p:u:")) != EOF) { - switch (c) { - case 'u': - if ((nchrg = fopen(optarg, "w")) == NULL) - openerr(optarg); - (void) chmod(optarg, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); - break; - case 'p': - pfile = optarg; - break; - default: - exit(1); - } - } - - if (pfile) { - if ((pwf = fopen(pfile, "r")) == NULL) { - openerr(pfile); - } - /* fill usglist with the user's in the passwd file */ - while ((pw = fgetpwent(pwf)) != NULL) { - if ((entry = hash_find(pw->pw_uid)) == NULL) - entry = hash_insert(pw->pw_uid); - validate_entry(entry, pw); - } - (void) fclose(pwf); - } - - /* charge the files listed in names to users listed in the usglist */ - while (fgets(fbuf, sizeof (fbuf), stdin) != NULL) { - if ((fb = strchr(fbuf, '\n')) != NULL) { - /* - * replace the newline char at the end of the - * filename with a null character - */ - *fb = '\0'; - } - charge(fbuf); - } - - output(); - - if (nchrg) - (void) fclose(nchrg); -#ifdef DEBUG - pdisk(); -#endif - return (0); -} - -/* - * create a new entry and insert. - */ -static struct disk * -hash_insert(uid_t uid) -{ - struct disk *curdisk; - int key = HASHKEY(uid); - - if ((curdisk = malloc(sizeof (struct disk))) == NULL) { - (void) fprintf(stderr, "acctdusg: cannot allocate memory " - "for hash table entry\n"); - exit(1); - } - curdisk->dsk_uid = uid; - curdisk->dsk_du = 0; - curdisk->validuser = 0; /* initially invalid */ - curdisk->next = usglist[key]; - usglist[key] = curdisk; - return (curdisk); -} - -/* - * return the disk entry for given uid. return NULL if not found. - */ -static struct disk * -hash_find(uid_t uid) -{ - struct disk *curdisk; - - for (curdisk = usglist[HASHKEY(uid)]; - curdisk != NULL; curdisk = curdisk->next) { - if (curdisk->dsk_uid == uid) { - return (curdisk); - } - } - return (NULL); -} - -static void -openerr(char *file) -{ - (void) fprintf(stderr, "Cannot open %s\n", file); - exit(1); -} - -static void -output(void) -{ - int index; - struct disk *entry; - - for (index = 0; index < MAXUSERS; index++) { - for (entry = usglist[index]; - entry != NULL; entry = entry->next) { - if (entry->dsk_du != 0) { - (void) printf("%ld\t%s\t%lld\n", - entry->dsk_uid, - entry->dsk_name, - entry->dsk_du); - } - } - } -} - -/* - * Initialize the disk entry for a valid passwd entry. - */ -static void -validate_entry(struct disk *entry, struct passwd *pw) -{ - (void) strlcpy(entry->dsk_name, pw->pw_name, - sizeof (entry->dsk_name)); - entry->validuser = 1; -} - -static void -charge(char *n) -{ - struct stat statb; - struct disk *entry; - struct passwd *pw; - - if (lstat(n, &statb) == -1) - return; - - /* - * do not count the duplicate entries. - */ - if (statb.st_nlink > 1) { - switch (add_tnode(&tree, statb.st_dev, statb.st_ino)) { - case 0: - /* already exist */ - return; - case 1: - /* added */ - break; - default: - perror("acctdusg"); - exit(1); - } - } - - /* - * st_blocks is not defined for character/block special files. - */ - if (S_ISCHR(statb.st_mode) || S_ISBLK(statb.st_mode)) - statb.st_blocks = 0; - - /* - * Files with unknown uid should go into nchrg. Otherwise, we try - * creating new entry for the uid. - */ - if ((entry = hash_find(statb.st_uid)) == NULL) { - pw = getpwuid(statb.st_uid); - entry = hash_insert(statb.st_uid); - if (pw != NULL) { - validate_entry(entry, pw); - } - } - - if (entry != NULL && entry->validuser) { - entry->dsk_du += statb.st_blocks; - } else if (nchrg) { - (void) fprintf(nchrg, "%9ld\t%7llu\t%s\n", - statb.st_uid, statb.st_blocks, n); - } -} - -#ifdef DEBUG -static void -pdisk() -{ - int index; - struct disk *entry; - - for (index = 0; index < MAXUSERS; index++) { - for (entry = usglist[index]; - entry != NULL; entry = entry->next) { - (void) fprintf(stderr, "%.8s\t%9ld\t%7llu\n", - entry->dsk_name, - entry->dsk_uid, - entry->dsk_du); - } - } - -} -#endif
--- a/usr/src/cmd/acct/acctmerg.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,269 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * acctmerg [-a] [-i] [-p] [-t] [-u] [-v] [file...] - * -a output in tacct.h/ascii (instead of tacct.h) - * -i input is in tacct.h/ascii (instead of tacct.h) - * -p print input files with no processing - * -t output single record that totals all input - * -u summarize by uid, rather than uid/name - * -v output in verbose tacct.h/ascii - * reads std input and 0-NFILE files, all in tacct.h format, - * sorted by uid/name. - * merge/adds all records with same uid/name (or same uid if -u, - * or all records if -t], writes to std. output - * (still in tacct.h format) - * note that this can be used to summarize the std input - */ - -#include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <stdlib.h> - -int nfile; /* index of last used in fl */ -FILE *fl[NFILE]; - -struct tacct tb[NFILE]; /* current record from each file */ -struct tacct tt = { - 0, - "TOTAL" -}; -int asciiout; -int asciiinp; -int printonly; -int totalonly; -int uidsum; -int verbose; - -int exitcode = 0; - -void prtacct(struct tacct *); -struct tacct *getleast(void); -void output(struct tacct *); -void tacctadd(struct tacct *, struct tacct *); -void sumcurr(struct tacct *); - -int -main(int argc, char **argv) -{ - int i; - struct tacct *tp; - - fl[0] = stdin; - - while (--argc > 0) { - if (**++argv == '-') - switch (*++*argv) { - case 'a': - asciiout++; - continue; - case 'i': - asciiinp++; - continue; - case 'p': - printonly++; - continue; - case 't': - totalonly++; - continue; - case 'u': - uidsum++; - continue; - case 'v': - verbose++; - asciiout++; - continue; - } - else { - if (++nfile >= NFILE) { - fprintf(stderr, "acctmerg: >%d files\n", NFILE); - exit(1); - } - if ((fl[nfile] = fopen(*argv, "r")) == NULL) { - fprintf(stderr, "acctmerg: can't open %s\n", *argv); - exitcode = 1; - /* exit(1); */ - } - } - } - - if (printonly) { - for (i = 0; i <= nfile; i++) - while (getnext(i)) - prtacct(&tb[i]); - exit(exitcode); - } - - for (i = 0; i <= nfile; i++) - if(getnext(i) == 0) { - fprintf(stderr,"acctmerg: read error file %d. File may be empty.\n", i); - exitcode = 2; - - } - - while ((tp = getleast()) != NULL) /* get least uid of all files, */ - sumcurr(tp); /* sum all entries for that uid, */ - if (totalonly) /* and write the 'summed' record */ - output(&tt); - - exit(exitcode); -} - -/* - * getleast returns ptr to least (lowest uid) element of current - * avail, NULL if none left; always returns 1st of equals - */ -struct tacct * -getleast(void) -{ - struct tacct *tp, *least; - - least = NULL; - for (tp = tb; tp <= &tb[nfile]; tp++) { - if (tp->ta_name[0] == '\0') - continue; - if (least == NULL || - tp->ta_uid < least->ta_uid || - ((tp->ta_uid == least->ta_uid) && - !uidsum && - (strncmp(tp->ta_name, least->ta_name, NSZ) < 0))) - least = tp; - } - return(least); -} - -/* - * sumcurr sums all entries with same uid/name (into tp->tacct record) - * writes it out, gets new entry - */ -void -sumcurr(struct tacct *tp) -{ - struct tacct tc; - char *memcpy(); - - memcpy(&tc, tp, sizeof(struct tacct)); - tacctadd(&tt, tp); /* gets total of all uids */ - getnext(tp-&tb[0]); /* get next one in same file */ - while (tp <= &tb[nfile]) - if (tp->ta_name[0] != '\0' && - tp->ta_uid == tc.ta_uid && - (uidsum || EQN(tp->ta_name, tc.ta_name))) { - tacctadd(&tc, tp); - tacctadd(&tt, tp); - getnext(tp-&tb[0]); - } else - tp++; /* look at next file */ - if (!totalonly) - output(&tc); -} - -void -tacctadd(struct tacct *t1, struct tacct *t2) -{ - t1->ta_cpu[0] = t1->ta_cpu[0] + t2->ta_cpu[0]; - t1->ta_cpu[1] = t1->ta_cpu[1] + t2->ta_cpu[1]; - t1->ta_kcore[0] = t1->ta_kcore[0] + t2->ta_kcore[0]; - t1->ta_kcore[1] = t1->ta_kcore[1] + t2->ta_kcore[1]; - t1->ta_con[0] = t1->ta_con[0] + t2->ta_con[0]; - t1->ta_con[1] = t1->ta_con[1] + t2->ta_con[1]; - t1->ta_du = t1->ta_du + t2->ta_du; - t1->ta_pc += t2->ta_pc; - t1->ta_sc += t2->ta_sc; - t1->ta_dc += t2->ta_dc; - t1->ta_fee += t2->ta_fee; -} - -void -output(struct tacct *tp) -{ - if (asciiout) - prtacct(tp); - else - fwrite(tp, sizeof(*tp), 1, stdout); -} - -/* - * getnext reads next record from stream i, returns 1 if one existed - */ -int -getnext(int i) -{ - struct tacct *tp; - - tp = &tb[i]; - tp->ta_name[0] = '\0'; - if (fl[i] == NULL) - return(0); - if (asciiinp) { - if (fscanf(fl[i], - "%ld\t%s\t%e %e %e %e %e %e %e %lu\t%hu\t%hu\t%hu", - &tp->ta_uid, - tp->ta_name, - &tp->ta_cpu[0], &tp->ta_cpu[1], - &tp->ta_kcore[0], &tp->ta_kcore[1], - &tp->ta_con[0], &tp->ta_con[1], - &tp->ta_du, - &tp->ta_pc, - &tp->ta_sc, - &tp->ta_dc, - &tp->ta_fee) != EOF) - return(1); - } else { - if (fread(tp, sizeof(*tp), 1, fl[i]) == 1) - return(1); - } - fclose(fl[i]); - fl[i] = NULL; - return(0); -} - -char fmt[] = "%ld\t%.*s\t%.0f\t%.0f\t%.0f\t%.0f\t%.0f\t%.0f\t%.0f\t%lu\t%hu\t%hu\t%hu\n"; -char fmtv[] = "%ld\t%.*s\t%e %e %e %e %e %e %e %lu %hu\t%hu\t%hu\n"; - -void -prtacct(struct tacct *tp) -{ - printf(verbose ? fmtv : fmt, - tp->ta_uid, - OUTPUT_NSZ, - tp->ta_name, - tp->ta_cpu[0], tp->ta_cpu[1], - tp->ta_kcore[0], tp->ta_kcore[1], - tp->ta_con[0], tp->ta_con[1], - tp->ta_du, - tp->ta_pc, - tp->ta_sc, - tp->ta_dc, - tp->ta_fee); -}
--- a/usr/src/cmd/acct/accton.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * accton - calls syscall with super-user privileges - */ - -#include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <errno.h> -#include <sys/stat.h> -#include <pwd.h> -#include <fcntl.h> -#include <stdlib.h> - -uid_t admuid; -struct passwd *pwd; - -void ckfile(char *); - -int -main(int argc, char **argv) -{ - uid_t uid; - - uid = getuid(); - if ((pwd = getpwnam("adm")) == NULL) { - perror("cannot determine adm's uid"), exit(1); - } - admuid = pwd->pw_uid; - if (uid == ROOT || uid == admuid) { - if (setuid(ROOT) == ERR) { - perror("cannot setuid (check command mode and owner)"); - exit(1); - } - if (argv[1]) - ckfile(argv[1]); - if (acct(argc > 1 ? argv[1] : 0) < 0) { - perror(argv[1]), exit(1); - } - exit(0); - - } - fprintf(stderr, "%s: permission denied\n", argv[0]); - exit(1); -} - -void -ckfile(char *admfile) -{ - struct stat stbuf; - struct stat *s = &stbuf; - int fd; - - if ((fd = open(admfile, O_RDONLY|O_CREAT, 0644)) == ERR) { - perror("creat"), exit(1); - } - - if (fstat(fd, s) == ERR) { - perror("fstat"); - exit(1); - } - - if (s->st_uid != admuid || s->st_gid != (gid_t)admuid) - if (fchown(fd, admuid, (gid_t)admuid) == ERR) { - perror("cannot change owner"), exit(1); - } - - /* was if(s->st_mode & 0777 != 0664) */ - if ((s->st_mode & S_IAMB) != S_IRUSR|S_IWUSR|S_IRGRP|S_IWUSR|S_IROTH) - if (fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IWUSR|S_IROTH) == ERR) { - perror("cannot chmod"), exit(1); - } - - (void) close(fd); -}
--- a/usr/src/cmd/acct/acctprc.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,173 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * acctprc - * reads std. input (acct.h format), - * writes std. output (tacct format) - * sorted by uid - * adds login names - */ - -#include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <sys/acct.h> -#include <string.h> -#include <search.h> -#include <stdlib.h> - -struct acct ab; -struct ptmp pb; -struct tacct tb; - -struct utab { - uid_t ut_uid; - char ut_name[NSZ]; - float ut_cpu[2]; /* cpu time (mins) */ - float ut_kcore[2]; /* kcore-mins */ - long ut_pc; /* # processes */ -} * ub; -static int usize; -void **root = NULL; - -void output(void); -void enter(struct ptmp *); - -int -main(int argc, char **argv) -{ - long elaps[2]; - ulong_t etime, stime; - unsigned long mem; -#ifdef uts - float expand(); -#else - ulong_t expand(); -#endif - - while (fread(&ab, sizeof(ab), 1, stdin) == 1) { - if (!MYKIND(ab.ac_flag)) - continue; - pb.pt_uid = ab.ac_uid; - CPYN(pb.pt_name, NULL); - /* - * approximate cpu P/NP split as same as elapsed time - */ - if ((etime = SECS(expand(ab.ac_etime))) == 0) - etime = 1; - stime = expand(ab.ac_stime) + expand(ab.ac_utime); - mem = expand(ab.ac_mem); - if(pnpsplit(ab.ac_btime, etime, elaps) == 0) { - fprintf(stderr, "acctprc: could not calculate prime/non-prime hours\n"); - - exit(1); - } - pb.pt_cpu[0] = (double)stime * (double)elaps[0] / etime; - pb.pt_cpu[1] = (stime > pb.pt_cpu[0])? stime - pb.pt_cpu[0] : 0; - pb.pt_cpu[1] = stime - pb.pt_cpu[0]; - if (stime) - pb.pt_mem = (mem + stime - 1) / stime; - else - pb.pt_mem = 0; /* unlikely */ - enter(&pb); - } - output(); - exit(0); -} - -int node_compare(const void *node1, const void *node2) -{ - if (((const struct utab *)node1)->ut_uid > \ - ((const struct utab *)node2)->ut_uid) - return(1); - else if (((const struct utab *)node1)->ut_uid < \ - ((const struct utab *)node2)->ut_uid) - return(-1); - else return(0); -} - -void -enter(struct ptmp *p) -{ - double memk; - struct utab **pt; - - if ((ub = (struct utab *)malloc(sizeof (struct utab))) == NULL) { - fprintf(stderr, "acctprc: malloc fail!\n"); - exit(2); - } - - ub->ut_uid = p->pt_uid; - CPYN(ub->ut_name, p->pt_name); - ub->ut_cpu[0] = MINT(p->pt_cpu[0]); - ub->ut_cpu[1] = MINT(p->pt_cpu[1]); - memk = KCORE(pb.pt_mem); - ub->ut_kcore[0] = memk * MINT(p->pt_cpu[0]); - ub->ut_kcore[1] = memk * MINT(p->pt_cpu[1]); - ub->ut_pc = 1; - - if (*(pt = (struct utab **)tsearch((void *)ub, (void **)&root, \ - node_compare)) == NULL) { - fprintf(stderr, "Not enough space available to build tree\n"); - exit(1); - } - - if (*pt != ub) { - (*pt)->ut_cpu[0] += MINT(p->pt_cpu[0]); - (*pt)->ut_cpu[1] += MINT(p->pt_cpu[1]); - (*pt)->ut_kcore[0] += memk * MINT(p->pt_cpu[0]); - (*pt)->ut_kcore[1] += memk * MINT(p->pt_cpu[1]); - (*pt)->ut_pc++; - free(ub); - } -} - -void print_node(const void *node, VISIT order, int level) { - - if (order == postorder || order == leaf) { - tb.ta_uid = (*(struct utab **)node)->ut_uid; - CPYN(tb.ta_name, (char *)uidtonam((*(struct utab **)node)->ut_uid)); - tb.ta_cpu[0] = (*(struct utab **)node)->ut_cpu[0]; - tb.ta_cpu[1] = (*(struct utab **)node)->ut_cpu[1]; - tb.ta_kcore[0] = (*(struct utab **)node)->ut_kcore[0]; - tb.ta_kcore[1] = (*(struct utab **)node)->ut_kcore[1]; - tb.ta_pc = (*(struct utab **)node)->ut_pc; - fwrite(&tb, sizeof(tb), 1, stdout); - } -} - -void -output(void) -{ - twalk((struct utab *)root, print_node); -}
--- a/usr/src/cmd/acct/acctprc1.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,306 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * acctprc1 [ctmpfile] - * reads std. input (acct.h format), adds login names - * writes std. output (ptmp.h/ascii format) - * if ctmpfile is given, it is expected have ctmp.h/ascii data, - * sorted by uid/name; it is used to make better guesses at login names - */ - -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <stdio.h> -#include <errno.h> -#include <sys/acct.h> -#include <stdlib.h> - -#define MYKIND(flag) ((flag & ACCTF) == 0) - -struct acct ab; -struct ctmp cb; -struct ptmp pb; - -int a_usize = A_USIZE; -struct urec { /* 1 for each distinct uid/name */ - uid_t ur_uid; /* sorted by uid/name */ - char ur_name[NSZ]; - struct srec *ur_srec; /* ptr to first session */ - short ur_cnt; /* # sessions */ -} * ur; - -struct urec *urlast; - -int a_ssize = A_SSIZE; -int ssize; - -struct srec { /* 1 for each distinct session */ - dev_t sr_tty; /* dev, used to connect with process*/ - time_t sr_start; /* start time of session */ - time_t sr_end; /* end time of session */ -} * sr; - -char *getname(uid_t, dev_t, time_t); -void readctmp(char *); -char *getnamc(uid_t, dev_t, time_t); -int aread(int); - -char *uidtonam(); - -int -main(int argc, char **argv) -{ - long elaps[2]; - ulong_t etime, stime; - unsigned long mem; - ulong_t expand(); - int ver; /* version of acct struct */ - int aread(); - - if ((ur = (struct urec *) calloc(a_usize, - sizeof (struct urec))) == NULL) { - fprintf(stderr, "acctpr1: Cannot allocate memory\n"); - exit(3); - } - - urlast = ur; - if ((sr = (struct srec *) calloc(a_ssize, - sizeof (struct srec))) == NULL) { - fprintf(stderr, "acctpr1: Cannot allocate memory\n"); - exit(3); - } - - while (--argc > 0) { - if (**++argv == '-') - switch(*++*argv) { - } - else { - readctmp(*argv); - } - } - - - if (fread((char *)&ab, sizeof(struct acct), 1, stdin) != 1) - exit(1); - else if (ab.ac_flag & AEXPND) - ver = 2; /* 4.0 acct structure */ - else - ver = 1; /* 3.x acct structure */ - - rewind(stdin); - - while (aread(ver) == 1) { - if (!MYKIND(ab.ac_flag)) - continue; - pb.pt_uid = ab.ac_uid; - CPYN(pb.pt_name, getname(ab.ac_uid, ab.ac_tty, ab.ac_btime)); - /* - * approximate cpu P/NP split as same as elapsed time - */ - if ((etime = SECS(expand(ab.ac_etime))) == 0) - etime = 1; - stime = expand(ab.ac_stime) + expand(ab.ac_utime); - mem = expand(ab.ac_mem); - if(pnpsplit(ab.ac_btime, etime, elaps) == 0) { - fprintf(stderr, "acctprc1: could not calculate prime/non-prime hours\n"); - - exit(1); - } - pb.pt_cpu[0] = (double)stime * (double)elaps[0] / etime; - pb.pt_cpu[1] = (stime > pb.pt_cpu[0])? stime - pb.pt_cpu[0] : 0; - pb.pt_cpu[1] = stime - pb.pt_cpu[0]; - if (stime) - pb.pt_mem = (mem + stime - 1) / stime; - else - pb.pt_mem = 0; /* unlikely */ - printf("%ld\t%.*s\t%lu\t%lu\t%u\n", - pb.pt_uid, - OUTPUT_NSZ, - pb.pt_name, - pb.pt_cpu[0], pb.pt_cpu[1], - pb.pt_mem); - } - - exit(0); -} - -/* - * return ptr to name corresponding to uid - * try ctmp first, then use uidtonam (internal list or passwd file) - */ -char * -getname(uid_t uid, dev_t tty, time_t start) -{ - char *p; - - if ((p = getnamc(uid, tty, start)) != NULL) - return (p); - return (uidtonam(uid)); -} - -/* - * read ctmp file, build up urec-srec data structures for - * later use by getnamc - */ -void -readctmp(char *fname) -{ - FILE *fp; - struct urec *up; - struct srec *sp; - int i = 0, j = 0, k=0; - - if ((fp = fopen(fname, "r")) == NULL) { - fprintf(stderr, "acctprc1: can't open %s\n", fname); - return; - } - - up = NULL; - sp = sr; - - while (fscanf(fp, "%hd\t%ld\t%s\t%lu\t%lu\t%lu\t%*[^\n]", - &cb.ct_tty, - &cb.ct_uid, - cb.ct_name, - &cb.ct_con[0], - &cb.ct_con[1], - &cb.ct_start) != EOF) { - if (up == NULL || cb.ct_uid != up->ur_uid || - !EQN(cb.ct_name, up->ur_name)) { - if (up == NULL) - up = ur; - if (++up >= &ur[a_usize]) { - a_usize = a_usize + A_USIZE; - if ((ur = reallocarray(ur, a_usize, - sizeof (struct urec))) == NULL) { - fprintf(stderr, "acctprc1: 1 Cannot reallocate memory\n"); - exit(2); - } - up = &ur[a_usize - A_USIZE]; - } - up->ur_uid = cb.ct_uid; - CPYN(up->ur_name, cb.ct_name); - up->ur_srec = sp; - up->ur_cnt = 0; - } - - if (sp >= &sr[a_ssize-1]) { - a_ssize = a_ssize + A_SSIZE; - if ((sr = reallocarray(sr, a_ssize, - sizeof (struct srec))) == NULL) { - fprintf(stderr, "acctprc1: 2 Cannot reallocate memory\n"); - printf("errno=%d\n", errno); - exit(2); - } - sp = &sr[a_ssize - A_SSIZE]; - } - - sp->sr_tty = cb.ct_tty; - sp->sr_start = cb.ct_start; - sp->sr_end = cb.ct_start + cb.ct_con[0] + cb.ct_con[1]; - sp++; - up->ur_cnt++; - } - if (up != NULL) - urlast = ++up; - fclose(fp); -} - -/* - * using urec-srec data (if any), make best guess at login name - * corresponding to uid, return ptr to the name. - * must match on tty; use start time to help guess - * for any urec having same uid as uid, search array of associated - * srecs for those having same tty - * if start time of process is within range of session, that's it - * if none can be found within range, give it to person of same uid - * who last logged off on that terminal - */ -char * -getnamc(uid_t uid, dev_t tty, time_t start) -{ - struct urec *up; - struct srec *sp; - struct srec *splast; - long latest; - char *guess; - - latest = 0; - guess = NULL; - for (up = ur; up < urlast && uid >= up->ur_uid; up++) - if (uid == up->ur_uid) { - sp = up->ur_srec; - splast = sp+up->ur_cnt; - for (; sp < splast; sp++) - if (tty == sp->sr_tty) { - if (start >= sp->sr_start && - start <= sp->sr_end) - return(up->ur_name); - if (start >= sp->sr_start && - sp->sr_end > latest) { - latest = sp->sr_end; - guess = up->ur_name; - } - } - } - - return(guess); -} -int -aread(int ver) -{ - struct o_acct oab; - int ret; - - if (ver != 2) { - if ((ret = fread((char *)&oab, sizeof(struct o_acct), 1, stdin)) == 1){ - /* copy SVR3 acct struct to SVR4 acct struct */ - ab.ac_flag = oab.ac_flag | AEXPND; - ab.ac_stat = oab.ac_stat; - ab.ac_uid = (uid_t) oab.ac_uid; - ab.ac_gid = (gid_t) oab.ac_gid; - ab.ac_tty = (dev_t) oab.ac_tty; - ab.ac_btime = oab.ac_btime; - ab.ac_utime = oab.ac_utime; - ab.ac_stime = oab.ac_stime; - ab.ac_mem = oab.ac_mem; - ab.ac_io = oab.ac_io; - ab.ac_rw = oab.ac_rw; - strcpy(ab.ac_comm, oab.ac_comm); - } - } else - ret = fread((char *)&ab, sizeof(struct acct), 1, stdin); - - - return(ret != 1 ? 0 : 1); -}
--- a/usr/src/cmd/acct/acctprc2.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#pragma ident "%Z%%M% %I% %E% SMI" -/* - * acctprc2 <ptmp1 >ptacct - * reads std. input (in ptmp.h/ascii format) - * hashes items with identical uid/name together, sums times - * sorts in uid/name order, writes tacct.h records to output - */ - -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <stdio.h> -#include <string.h> -#include <search.h> -#include <stdlib.h> - -struct ptmp pb; -struct tacct tb; - -struct utab { - uid_t ut_uid; - char ut_name[NSZ]; - float ut_cpu[2]; /* cpu time (mins) */ - float ut_kcore[2]; /* kcore-mins */ - long ut_pc; /* # processes */ -} * ub; - -static int usize; -void **root = NULL; - -void output(void); -void enter(struct ptmp *); - -int -main(int argc, char **argv) -{ - - while (scanf("%ld\t%s\t%lu\t%lu\t%u", - &pb.pt_uid, - pb.pt_name, - &pb.pt_cpu[0], &pb.pt_cpu[1], - &pb.pt_mem) != EOF) - enter(&pb); - output(); - exit(0); -} - -int node_compare(const void *node1, const void *node2) -{ - if (((const struct utab *)node1)->ut_uid > \ - ((const struct utab *)node2)->ut_uid) - return(1); - else if (((const struct utab *)node1)->ut_uid < \ - ((const struct utab *)node2)->ut_uid) - return(-1); - else return(strcmp(((const struct utab *) node1)->ut_name, - ((const struct utab *) node2)->ut_name)); - -} - -void -enter(struct ptmp *p) -{ - unsigned int i; - double memk; - struct utab **pt; - - /* clear end of short users' names */ - for(i = strlen(p->pt_name) + 1; i < NSZ; p->pt_name[i++] = '\0') ; - - if ((ub = (struct utab *)malloc(sizeof (struct utab))) == NULL) { - fprintf(stderr, "acctprc2: malloc fail!\n"); - exit(2); - } - - ub->ut_uid = p->pt_uid; - CPYN(ub->ut_name, p->pt_name); - ub->ut_cpu[0] = MINT(p->pt_cpu[0]); - ub->ut_cpu[1] = MINT(p->pt_cpu[1]); - memk = KCORE(pb.pt_mem); - ub->ut_kcore[0] = memk * MINT(p->pt_cpu[0]); - ub->ut_kcore[1] = memk * MINT(p->pt_cpu[1]); - ub->ut_pc = 1; - - if (*(pt = (struct utab **)tsearch((void *)ub, (void **)&root, \ - node_compare)) == NULL) { - fprintf(stderr, "Not enough space available to build tree\n"); - exit(1); - } - - if (*pt != ub) { - (*pt)->ut_cpu[0] += MINT(p->pt_cpu[0]); - (*pt)->ut_cpu[1] += MINT(p->pt_cpu[1]); - (*pt)->ut_kcore[0] += memk * MINT(p->pt_cpu[0]); - (*pt)->ut_kcore[1] += memk * MINT(p->pt_cpu[1]); - (*pt)->ut_pc++; - free(ub); - } -} - -void print_node(const void *node, VISIT order, int level) { - if (order == postorder || order == leaf) { - tb.ta_uid = (*(struct utab **)node)->ut_uid; - CPYN(tb.ta_name, (*(struct utab **)node)->ut_name); - tb.ta_cpu[0] = ((*(struct utab **)node)->ut_cpu[0]); - tb.ta_cpu[1] = ((*(struct utab **)node)->ut_cpu[1]); - tb.ta_kcore[0] = (*(struct utab **)node)->ut_kcore[0]; - tb.ta_kcore[1] = (*(struct utab **)node)->ut_kcore[1]; - tb.ta_pc = (*(struct utab **)node)->ut_pc; - fwrite(&tb, sizeof(tb), 1, stdout); - } -} - -void -output(void) -{ - twalk((struct utab *)root, print_node); -}
--- a/usr/src/cmd/acct/acctwtmp.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* - * acctwtmp reason /var/log/wtmpx - * writes utmpx.h record (with current time) to specific file - * acctwtmp `uname` /var/log/wtmpx as part of startup - * acctwtmp pm /var/log/wtmpx (taken down for pm, for example) - */ -#include <stdio.h> -#include <sys/types.h> -#include "acctdef.h" -#include <utmpx.h> -#include <strings.h> -#include <stdlib.h> - -struct utmpx wb; - -int -main(int argc, char **argv) -{ - struct utmpx *p; - - if (argc < 3) - (void) fprintf(stderr, "Usage: %s reason wtmpx_file\n", - argv[0]), exit(1); - - (void) strncpy(wb.ut_line, argv[1], sizeof (wb.ut_line)); - wb.ut_line[11] = '\0'; - wb.ut_type = ACCOUNTING; - time(&wb.ut_xtime); - utmpxname(argv[2]); - setutxent(); - - if (pututxline(&wb) == NULL) - printf("acctwtmp - pututxline failed\n"); - endutxent(); - exit(0); -}
--- a/usr/src/cmd/acct/chargefee.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */ -# "chargefee login-name number" -# "emits tacct.h/ascii record to charge name $number" -cd /var/log -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -if test $# -lt 2; then - echo "usage: chargefee name number" >&2 - exit 1 -fi -_entry="`getent passwd $1`" -if test -z "${_entry}"; then - echo "can't find login name $1" >&2 - exit 2 -fi -case "$2" in --[0-9]*|[0-9]*);; -*) - echo "charge invalid: $2" >&2 - exit 3 -esac - -if test ! -r fee; then - nulladm fee -fi -_userid=`echo "${_entry}" | cut -d: -f3` # get the UID -echo "${_userid} $1 0 0 0 0 0 0 0 0 0 0 $2" >>fee
--- a/usr/src/cmd/acct/ckpacct.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - -# -# Copyright 1997 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */ -# periodically check the size of /var/log/pacct -# if over $1 blocks (default: maxi 200, mini 500), execute -# turnacct switch - -_adm=/var/log -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -trap "rm -f /var/log/cklock*; exit 0" 0 1 2 3 9 15 -export PATH - -if [ -f uts -a uts ] -then - _max=${1-200} -else - _max=${1-500} -fi -_MIN_BLKS=500 -cd /var/log - -# set up lock files to prevent simultaneous checking - -cp /dev/null cklock -chmod 400 cklock -ln cklock cklock1 -if test $? -ne 0 ; then exit 1; fi - -# If there are less than $_MIN_BLKS free blocks left on the /var/log -# file system, turn off the accounting (unless things improve -# the accounting wouldn't run anyway). If something has -# returned the file system space, restart accounting. This -# feature relies on the fact that ckpacct is kicked off by the -# cron at least once per hour. - - -_blocks=`df $_adm | sed 's/.*://' | awk '{ print $1 }'` - -if [ "$_blocks" -lt $_MIN_BLKS -a -f /tmp/acctoff ];then - echo "ckpacct: $_adm still low on space ($_blocks blks); \c" - echo "acctg still off" - ( echo "ckpacct: $_adm still low on space ($_blocks blks); \c" - echo "acctg still off" ) | mailx root adm - exit 1 -elif [ "$_blocks" -lt $_MIN_BLKS ];then - echo "ckpacct: $_adm too low on space ($_blocks blks); \c" - echo "turning acctg off" - ( echo "ckpacct: $_adm too low on space ($_blocks blks); \c" - echo "turning acctg off" ) | mailx root adm - nulladm /tmp/acctoff - turnacct off - exit 1 -elif [ -f /tmp/acctoff ];then - echo "ckpacct: $_adm free space restored; turning acctg on" - echo "ckpacct: $_adm free space restored; turning acctg on" | \ - mailx root adm - rm /tmp/acctoff - turnacct on -fi - -_cursize="`du -s pacct | sed 's/ .*//'`" -if [ "${_max}" -lt "${_cursize}" ]; then - turnacct switch -fi
--- a/usr/src/cmd/acct/closewtmp.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ -/* Copyright (c) 1999, 2000 by Sun Microsystems, Inc. */ -/* All rights reserved. */ - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ - -/* - * fudge an entry to wtmpx for each user who is still logged on when - * acct is being run. This entry marks a DEAD_PROCESS, and the - * current time as time stamp. This should be done before connect - * time is processed. Called by runacct. - */ - -#include <stdio.h> -#include <sys/types.h> -#include <utmpx.h> - -int -main(int argc, char **argv) -{ - struct utmpx *utmpx; - - setutxent(); - while ((utmpx = getutxent()) != NULL) { - if (utmpx->ut_type == USER_PROCESS) { - utmpx->ut_type = DEAD_PROCESS; - time(&utmpx->ut_xtime); - (void) updwtmpx(WTMPX_FILE, utmpx); - } - } - endutxent(); - return (0); -}
--- a/usr/src/cmd/acct/dodisk.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.13 */ -# 'perform disk accounting' -PATH=:/usr/lib/acct:/usr/bin:/usr/sbin -export PATH -if [ -f /usr/bin/uts -a /usr/bin/uts ] -then - format="dev mnt type comment" -else - format="special dev mnt fstype fsckpass automnt mntflags" -fi -_dir=/var/log -_pickup=acct/nite -set -- `getopt o $*` -if [ $? -ne 0 ] -then - echo "Usage: $0 [ -o ] [ filesystem ... ]" >&2 - exit 1 -fi -for i in $*; do - case $i in - -o) SLOW=1; shift;; - --) shift; break;; - esac -done - -cd ${_dir} - -if [ "$SLOW" = "" ] -then - if [ $# -lt 1 ] - then - if [ -f /usr/bin/uts -a /usr/bin/uts ] - then - DEVLIST=/etc/checklist - else - DEVLIST=/etc/vfstab - fi - while : - do - if read $format - then - if [ -z "$special" ] - then - continue - elif [ `expr $special : '\(.\)'` = \# ] - then - continue - fi - if [ "$fsckpass" = "-" ] - then - continue - fi - if [ $fstype != ufs ] && [ $fstype != vxfs ] - then - continue - fi - - # Make sure FS is mounted - if egrep -s "^${special}[ ]+${mnt}[ ]" /etc/mnttab - then - find $mnt -mount -print | \ - acctdusg > \ - `echo $dev | sed s-/-_-g`.dtmp & - fi - else - wait - break - fi - done < $DEVLIST - if [ "`echo *.dtmp`" != "*.dtmp" ] - then - awk -e ' - {tot[$1] += $3; if (name[$1] == "") name[$1] = "" $2} -END {for (i in tot) printf "%d\t%s\t%d\n", i, name[i], tot[i]}' *.dtmp > dtmp - rm -f *.dtmp - else - > dtmp - fi - else - find $* -mount -print | acctdusg > dtmp - fi -else - if [ $# -lt 1 ] - then - args="/" - else - args="$*" - fi - for i in $args; do - if [ ! -d $i ] - then - echo "$0: $i is not a directory -- ignored" >&2 - else - dir="$i $dir" - fi - done - if [ "$dir" = "" ] - then - echo "$0: No data" >&2 - > dtmp - else - find $dir -print | acctdusg > dtmp - fi -fi - -sort +0n +1 dtmp | acctdisk > ${_pickup}/disktacct -chmod 644 ${_pickup}/disktacct -chown adm ${_pickup}/disktacct
--- a/usr/src/cmd/acct/fwtmp.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,156 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include "acctdef.h" -#include <utmpx.h> -#include <locale.h> -#include <stdlib.h> - -struct utmpx Ut; -static char time_buf[50]; - -static int inp(FILE *, struct utmpx *); - -int -main(int c, char **v) -{ - - int iflg, cflg; - - (void) setlocale(LC_ALL, ""); - - iflg = cflg = 0; - - while (--c > 0) { - if (**++v == '-') - while (*++*v) - switch (**v) { - case 'c': - cflg++; - continue; - case 'i': - iflg++; - continue; - } - } - - for (;;) { - if (iflg) { - if (inp(stdin, &Ut) == EOF) - break; - } else { - if (fread(&Ut, sizeof (Ut), 1, stdin) != 1) - break; - } - if (cflg) - fwrite(&Ut, sizeof (Ut), 1, stdout); - else { - cftime(time_buf, DATE_FMT, &Ut.ut_xtime); - printf("%-*.*s %-4.4s %-*.*s %9d %2hd " - "%4.4ho %4.4ho %ld %ld %d %hd %-.*s %s", - NSZ, - NSZ, - Ut.ut_name, - Ut.ut_id, - LINESZ, - LINESZ, - Ut.ut_line, - Ut.ut_pid, - Ut.ut_type, - Ut.ut_exit.e_termination, - Ut.ut_exit.e_exit, - Ut.ut_xtime, - Ut.ut_tv.tv_usec, - Ut.ut_session, - Ut.ut_syslen, - Ut.ut_syslen, - Ut.ut_host, - time_buf); - } - } - exit(0); -} - -static int -inp(FILE *file, struct utmpx *u) -{ - - char buf[BUFSIZ]; - char *p; - int i; - - if (fgets((p = buf), BUFSIZ, file) == NULL) - return (EOF); - - for (i = 0; i < NSZ; i++) /* Allow a space in name field */ - u->ut_name[i] = *p++; - for (i = NSZ-1; i >= 0; i--) { - if (u->ut_name[i] == ' ') - u->ut_name[i] = '\0'; - else - break; - } - p++; - - for (i = 0; i < 4; i++) - if ((u->ut_id[i] = *p++) == ' ') - u->ut_id[i] = '\0'; - p++; - - for (i = 0; i < LINESZ; i++) /* Allow a space in line field */ - u->ut_line[i] = *p++; - for (i = LINESZ-1; i >= 0; i--) { - if (u->ut_line[i] == ' ') - u->ut_line[i] = '\0'; - else - break; - } - - sscanf(p, "%d %hd %ho %ho %ld %ld %d %hd", - &u->ut_pid, - &u->ut_type, - &u->ut_exit.e_termination, - &u->ut_exit.e_exit, - &u->ut_xtime, - &u->ut_tv.tv_usec, - &u->ut_session, - &u->ut_syslen); - - if (u->ut_syslen > 1) - sscanf(p, "%*d %*hd %*ho %*ho %*ld %*ld %*d %*hd %s", - u->ut_host); - else - u->ut_host[0] = '\0'; - - return (1); -}
--- a/usr/src/cmd/acct/lastlogin.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */ -# "lastlogin - keep record of date each person last logged in" -# "bug - the date shown is usually 1 more than it should be " -# " because lastlogin is run at 4am and checks the last" -# " 24 hrs worth of process accounting info (in pacct)" -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -cd /var/log/acct -if test ! -r sum/loginlog; then - nulladm sum/loginlog -fi -# "cleanup loginlog - delete entries of those no longer in" -# "/etc/passwd and add an entry for those recently added" -# "line 1 - get file of current logins in same form as loginlog" -# "line 2 - merge the 2 files; use uniq to delete common" -# "lines resulting in those lines which need to be" -# "deleted or added from loginlog" -# "line 3 - result of sort will be a file with 2 copies" -# "of lines to delete and 1 copy of lines that are " -# "valid; use uniq to remove duplicate lines" -getent passwd | sed "s/\([^:]*\).*/00-00-00 \1/" |\ -sort +1 - sum/loginlog | uniq -u +10 |\ -sort +1 - sum/loginlog |uniq -u > sum/tmploginlog -cp sum/tmploginlog sum/loginlog -# "update loginlog" -_d="`date +%y-%m-%d`" -_day=`date +%m%d` -# "lines 1 and 2 - remove everything from the total" -# "acctng records with connect info except login" -# "name and adds the date" -# "line 3 - sorts in reverse order by login name; gets" -# "1st occurrence of each login name and resorts by date" -acctmerg -a < nite/ctacct.$_day | \ -sed -e "s/^[^ ]*[ ]\([^ ]*\)[ ].*/$_d \1/" | \ -nawk '/^00-00-00/ { - $0 = "00" $0 - } - /^[0-9][0-9]-/ { - d=substr($0,1,2); - if (d<=68) { - $0 = "20" $0 - } else { - $0 = "19" $0 - } - } - { print }' - sum/loginlog | \ -sort -r +1 | uniq +10 | sort | \ -nawk '/^[0-9][0-9][0-9][0-9]-/ { - $0 = substr($0,3) - } - { print }' > sum/tmploginlog -cp sum/tmploginlog sum/loginlog -rm -f sum/tmploginlog
--- a/usr/src/cmd/acct/monacct.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */ -# "this procedure should be run periodically ( by month or fiscal )" -_adm=/var/log -_sum=${_adm}/acct/sum -_fiscal=${_adm}/acct/fiscal -PATH=:/usr/lib/acct:/usr/bin:/usr/sbin -export PATH - - -#if test $# -ne 1; then -# echo "usage: monacct fiscal-number" -# exit -#fi - -_period=${1-`date +%m`} - -cd ${_adm} - -# "move summary tacct file to fiscal directory" -mv ${_sum}/tacct ${_fiscal}/tacct${_period} - -# "delete the daily tacct files" -rm -f ${_sum}/tacct???? - -# "restart summary tacct file" -nulladm ${_sum}/tacct - -# "move summary cms file to fiscal directory -mv ${_sum}/cms ${_fiscal}/cms${_period} - -# "restart summary cms file" -nulladm ${_sum}/cms - -# "remove old prdaily reports" -rm -f ${_sum}/rprt* - -# "produce monthly reports" -prtacct ${_fiscal}/tacct${_period} > ${_fiscal}/fiscrpt${_period} -acctcms -a -s ${_fiscal}/cms${_period} | \ -pr -h "TOTAL COMMAND SUMMARY FOR FISCAL ${_period}" >> ${_fiscal}/fiscrpt${_period} -pr -h "LAST LOGIN" -3 ${_sum}/loginlog >> ${_fiscal}/fiscrpt${_period} - -# "add commands here to do any charging of fees, etc" -exit
--- a/usr/src/cmd/acct/nulladm.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ -# "nulladm name..." -# "creates each named file mode 664" -# "make sure owned by adm (in case created by root)" -for _file -do - cp /dev/null $_file - chmod 664 $_file - chgrp adm $_file - chown adm $_file -done
--- a/usr/src/cmd/acct/prctmp.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */ -# "print session record file (ctmp.h/ascii) with headings" -# "prctmp file [heading]" -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -(cat <<!; cat $*) | pr -h "SESSIONS, SORTED BY ENDING TIME" - -MAJ/MIN CONNECT SECONDS START TIME SESSION START -DEVICE UID LOGIN PRIME NPRIME (NUMERIC) DATE TIME - - -!
--- a/usr/src/cmd/acct/prdaily.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - -# -# Copyright 1992 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.12 */ -# "prdaily prints daily report" -# "last command executed in runacct" -# "if given a date mmdd, will print that report" -PATH=/usr/lib/acct:/usr/bin:/usr/sbin - -while getopts cl i -do - case $i in - c) CMDEXCPT=1;; - l) LINEEXCPT=1;; - ?) echo Usage: prdaily [-c] [-l] [mmdd] >&2 - exit 2;; - esac -done -shift `expr $OPTIND - 1` -date=`date +%m%d` -_sysname="`uname -n`" -_nite=/var/log/acct/nite -_lib=/usr/lib/acct -_sum=/var/log/acct/sum - -cd ${_nite} -if [ `expr "$1" : [01][0-9][0-3][0-9]` -eq 4 -a "$1" != "$date" ]; then - if [ "$CMDEXCPT" = "1" ] - then - echo "Cannot print command exception reports except for `date '+%h %d'`" >&2 - exit 5 - fi - if [ "$LINEEXCPT" = "1" ] - then - acctmerg -a < ${_sum}/tacct$1 | awk -f ${_lib}/ptelus.awk - exit $? - fi - cat ${_sum}/rprt$1 - exit 0 -fi - -if [ "$CMDEXCPT" = 1 ] -then - acctcms -a -s ${_sum}/daycms | awk -f ${_lib}/ptecms.awk -fi -if [ "$LINEEXCPT" = 1 ] -then - acctmerg -a < ${_sum}/tacct${date} | awk -f ${_lib}/ptelus.awk -fi -if [ "$CMDEXCPT" = 1 -o "$LINEEXCPT" = 1 ] -then - exit 0 -fi -(cat reboots; echo ""; cat lineuse) | pr -h "DAILY REPORT FOR ${_sysname}" - -prtacct daytacct "DAILY USAGE REPORT FOR ${_sysname}" -pr -h "DAILY COMMAND SUMMARY" daycms -pr -h "MONTHLY TOTAL COMMAND SUMMARY" cms -pr -h "LAST LOGIN" -3 ../sum/loginlog -exit 0
--- a/usr/src/cmd/acct/prtacct.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */ -# "print daily/summary total accounting (any file in tacct.h format)" -# "prtacct file [heading]" -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -_filename=${1?"missing filename"} -(cat <<!; acctmerg -t -a <${_filename}; acctmerg -p <${_filename}) | pr -h "$2" - LOGIN CPU (MINS) KCORE-MINS CONNECT (MINS) DISK # OF # OF # DISK FEE -UID NAME PRIME NPRIME PRIME NPRIME PRIME NPRIME BLOCKS PROCS SESS SAMPLES -!
--- a/usr/src/cmd/acct/ptecms.awk Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -BEGIN { - MAXCPU = 20.0 # report if cpu usage greater than this - MAXKCORE = 1000.0 # report if KCORE usage is greater than this -} - -NF == 4 { print "\t\t\t\t" $1 " Time Exception Command Usage Summary" } - -NF == 3 { print "\t\t\t\tCommand Exception Usage Summary" } - -NR == 1 { - MAXCPU = MAXCPU + 0.0 - MAXKCORE = MAXKCORE + 0.0 - print "\t\t\t\tTotal CPU > " MAXCPU " or Total KCORE > " MAXKCORE -} - -NF <= 4 && length != 0 { next } - -$1 == "COMMAND" || $1 == "NAME" { print; next } - -NF == 10 && ( $4 > MAXCPU || $3 > MAXKCORE ) && $1 != "TOTALS" - -NF == 13 && ( $5 + $6 > MAXCPU || $4 > MAXKCORE ) && $1 != "TOTALS" - -length == 0 - -
--- a/usr/src/cmd/acct/ptelus.awk Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8 */ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -BEGIN { - MAXCPU = 20. # report if cpu usage is greater than this - MAXKCORE = 500. # report is Kcore usage is greater than this - MAXCONNECT = 120. # report if connect time is greater than this -} - -NR == 1 { - MAXCPU = MAXCPU + 0 - MAXKCORE = MAXKCORE + 0 - MAXCONNECT = MAXCONNECT + 0 - printf "Logins with exceptional Prime/Non-prime Time Usage\n" - printf ( "CPU > %d or KCORE > %d or CONNECT > %d\n\n\n", MAXCPU, MAXKCORE, MAXCONNECT) - printf "\tLogin\t\tCPU (mins)\tKCORE-mins\tCONNECT-mins\tdisk" - printf "\t# of\t# of\t# Disk\tfee\n" - printf "UID\tName\t\tPrime\tNprime\tPrime\tNprime\t" - printf "Prime\tNprime\tBlocks\tProcs\tSess\tSamples\n\n" -} - -$3 > MAXCPU || $4 > MAXCPU || $5 > MAXKCORE || $6 > MAXKCORE || $7 > MAXCONNECT || $8 > MAXCONNECT { - printf("%d\t%-8.8s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) -} -
--- a/usr/src/cmd/acct/remove.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */ -rm -f /var/log/acct/sum/wtmp* -rm -f /var/log/acct/sum/pacct* -rm -f /var/log/acct/nite/lock*
--- a/usr/src/cmd/acct/runacct.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,453 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */ -# "nitely accounting shell, should be run from cron (adm) at 4am" -# "does process, connect, disk, and fee accounting" -# "prepares command summaries" -# "shell is restartable and provides reasonable diagnostics" -_adm=/var/log -_nite=/var/log/acct/nite -_sum=/var/log/acct/sum -_wtmpx=/var/log/wtmpx -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -export PATH -_statefile=${_nite}/statefile -_active=${_nite}/active -_lastdate=${_nite}/lastdate -_date="`date +%m%d`" -_errormsg="\n\n************ ACCT ERRORS : see ${_active}${_date}********\n\n" -_MIN_BLKS=500 - -cd ${_adm} -# "make sure that 2 crons weren't started, or leftover problems" -date > ${_nite}/lock1 -chmod 400 ${_nite}/lock1 -ln ${_nite}/lock1 ${_nite}/lock -if test $? -ne 0; then - _lnkerr="\n\n*********** 2 CRONS or ACCT PROBLEMS***********\n\n\n" - (date ; echo "$_lnkerr" ) | logger -p daemon.err - echo "$_lnkerr" | mailx adm root - echo "ERROR: locks found, run aborted" >> ${_active} - rm -f ${_nite}/lock* - exit 1 -fi - -# Check to see if there is enough space in /var/log to do nitely accounting -# -_blocks=`df $_adm | sed 's/.*://' | awk '{ print $1 }'` -if [ "$_blocks" -le $_MIN_BLKS ];then - echo "runacct: Insufficient space in $_adm ($_blocks blks); \c" - echo "Terminating procedure" - ( echo "runacct: Insufficient space in $_adm ($_blocks blks); \c" - echo "Terminating procedure" ) > /tmp/accounting_tmpfile - cat /tmp/accounting_tmpfile >> ${_active} - cat /tmp/accounting_tmpfile | logger -p daemon.err - mailx root adm < /tmp/accounting_tmpfile - rm /tmp/accounting_tmpfile - - rm -f ${_nite}/lock* - exit 1 -fi - - -case $# in -0) -# "as called by the cron each day" - if test ! -r ${_lastdate} ; then - echo "0000" > ${_lastdate} - fi - if test "${_date}" = "`cat ${_lastdate}`"; then - (date; echo "${_errormsg}") | logger -p daemon.err - echo "${_errormsg}" | mailx root adm - echo "ERROR: acctg already run for `date`: check ${_lastdate}" >> ${_active} - rm -f ${_nite}/lock* - mv ${_active} ${_active}${_date} - exit 1 - fi - echo ${_date} > ${_lastdate} - echo "SETUP" > ${_statefile} - nulladm ${_active} - echo ${_date} > ${_active} # debuging - echo "\n\n\n\n\n********** SYSTEM ACCOUNTING STARTED `date` **********\n\n\n\n\n" | logger -p daemon.notice - echo ${_date} > ${_active} # debuging - ;; - -1) -# "runacct MMDD (date) will restart at current state" - _date=$1 - _errormsg="\n\n************ ACCT ERRORS : see ${_active}${_date}********\n\n" - echo "restarting acctg for ${_date} at `cat ${_statefile}`" >> ${_active} - echo "\n\n\n\n\n********** SYSTEM ACCOUNTING RESTARTED `date` **********\n\n\n\n\n" | logger -p daemon.notice - ;; - -2) -# "runacct MMDD STATE restart at specified state" - _date=$1 - _errormsg="\n\n************ ACCT ERRORS : see ${_active}${_date}********\n\n" - echo "restarting acctg for ${_date} at $2" >> ${_active} - echo "previous state was `cat ${_statefile}`" >> ${_active} - echo "$2" > ${_statefile} - echo "\n\n\n\n\n********** SYSTEM ACCOUNTING RESTARTED `date` **********\n\n\n\n\n" | logger -p daemon.notice - ;; -*) - (date; echo "${_errormsg}") | logger -p daemon.err - echo "${_errormsg}" | mailx root adm - echo "ERROR: runacct called with invalid arguments" > ${_active} - rm -f ${_nite}/lock* - mv ${_active} ${_active}${_date} - exit 1 - ;; -esac - - -# "processing is broken down into seperate, restartable states" -# "the statefile is updated at the end of each state so that the" -# "next loop through the while statement switches to the next state" -while [ 1 ] -do -case "`cat ${_statefile}`" in -SETUP) - -cd ${_adm} - -(date ; ls -l fee pacct* ${_wtmpx}* ) >> ${_active} - -# "switch current pacct file" -turnacct switch -_rc=$? -if test ${_rc} -ne 0; then - (date ; echo "${_errormsg}" ) | logger -p daemon.err - echo "${_errormsg}" | mailx root adm - echo "ERROR: turnacct switch returned rc=${_rc}" >> ${_active} - rm -f ${_nite}/lock* - mv ${_active} ${_active}${_date} - exit 1 -fi - -# " give pacct files unique names for easy restart " -for _i in pacct?* -do - if [ "${_i}" = "pacct?*" ] - then - rm -f ${_nite}/lock* - mv ${_active} ${_active}${_date} - exit 1 - fi - if test -r S${_i}.${_date} ; then - (date ; echo "${_errormsg}" ) | logger -p daemon.err - echo "${_errormsg}" | mailx root adm - echo "ERROR: S${_i}.${_date} already exists" >> ${_active} - echo "file setups probably already run" >> ${_active} - rm -f ${_nite}/lock* - mv ${_active} ${_active}${_date} - exit 1 - fi - mv ${_i} S${_i}.${_date} -done - - -# "add current time on end" -if test -r ${_nite}/wtmpx.${_date} ; then - (date ; echo "${_errormsg}" ) | logger -p daemon.err - echo "${_errormsg}" | mailx root adm - echo "ERROR: ${_nite}/wtmpx.${_date} already exists: run setup manually" > ${_active} - rm -f ${_nite}/lock* - mv ${_active} ${_active}${_date} - exit 1 -fi -closewtmp # fudge a DEAD_PROCESS for /var/wtmpx -cp ${_wtmpx} ${_nite}/${_date}.wtmpx -acctwtmp "runacct" ${_nite}/${_date}.wtmpx -nulladm ${_wtmpx} -utmp2wtmp # fudge active user from utmpx to wtmpx - -echo "files setups complete" >> ${_active} -echo "WTMPFIX" > ${_statefile} -;; - -WTMPFIX) -# "verify the integrity of the wtmpx file" -# "wtmpfix will automatically fix date changes" -cd ${_nite} -nulladm tmpwtmp wtmperror -wtmpfix < ${_date}.wtmpx > tmpwtmp 2>wtmperror -if test $? -ne 0 ; then - (date ; echo "${_errormsg}") | mailx root adm - echo "${_errormsg}" | logger -p daemon.err - echo "ERROR: wtmpfix errors see ${_nite}/wtmperror${_date}" >> ${_active} - rm -f ${_nite}/lock* - mv ${_active} ${_active}${_date} - mv wtmperror wtmperror${_date} - exit 1 -fi - -echo "wtmpx processing complete" >> ${_active} -echo "CONNECT" > ${_statefile} -;; - - -CONNECT) -# "produce connect records" -# "the lineuse and reboots files are used by prdaily" -cd ${_nite} -nulladm lineuse reboots log ctacct.${_date} -acctcon -l lineuse -o reboots < tmpwtmp 2> log > ctacct.${_date} - -# if the following test is true, then pnpsplit complained about -# the year and holidays not being up to date. This used to be -# a fatal error, but now it will continue to process the accounting. -# -if test -s log ; then - (date ; cat ${_nite}/log) | mailx adm root - echo "\n\n************ ACCT ERRORS : see ${_nite}log********\n\n" | logger -p daemon.err - cat ${_nite}/log >> ${_active}${_date} -fi - -echo "connect acctg complete" >> ${_active} -echo "PROCESS" > ${_statefile} -;; - - -PROCESS) -# "correlate Spacct and ptacct files by number" -# "will not process Spacct file if corresponding ptacct exists" -# "remove the ptacct file to rurun the Spacct file" -# "if death occurs here, rerunacct should remove last ptacct file" - -cd ${_nite} -for _Spacct in ${_adm}/Spacct*.${_date} -do - _ptacct=`basename ${_Spacct} | sed 's/Sp/pt/'` - if test -s ${_ptacct}; then - echo "WARNING: accounting already run for ${_Spacct}" \ - >> ${_active} - echo "WARNING: remove ${_nite}/${_ptacct} to rerun" \ - >> ${_active} - else - nulladm ${_ptacct} - acctprc < ${_Spacct} > ${_ptacct} - - echo "process acctg complete for ${_Spacct}" >> ${_active} - fi -done -echo "all process actg complete for ${_date}" >> ${_active} -echo "MERGE" > ${_statefile} -;; - - -MERGE) -cd ${_nite} -# "merge ctacct and ptacct files together" -acctmerg ptacct*.${_date} < ctacct.${_date} > daytacct - -echo "tacct merge to create daytacct complete" >> ${_active} -echo "FEES" > ${_statefile} -;; - - -FEES) -cd ${_nite} -# "merge in fees" -if test -s ${_adm}/fee; then - cp daytacct tmpdayt - sort +0n +2 ${_adm}/fee | acctmerg -i | acctmerg tmpdayt > daytacct - echo "merged fees" >> ${_active} - rm -f tmpdayt -else - echo "no fees" >> ${_active} -fi -echo "DISK" > ${_statefile} -;; - - -DISK) -cd ${_nite} -# "the last act of any disk acct procedure should be to mv its" -# "entire output file to disktacct, where it will be picked up" -if test -r disktacct; then - cp daytacct tmpdayt - acctmerg disktacct < tmpdayt > daytacct - echo "merged disk records" >> ${_active} - rm -f tmpdayt - mv disktacct /tmp/disktacct.${_date} -else - echo "no disk records" >> ${_active} -fi -echo "MERGETACCT" > ${_statefile} -;; - -MERGETACCT) -cd ${_adm}/acct -# "save each days tacct file in sum/tacct.${_date}" -# "if sum/tacct gets corrupted or lost, could recreate easily" -# "the monthly acctg procedure should remove all sum/tacct files" -cp nite/daytacct sum/tacct${_date} -if test ! -r sum/tacct; then - echo "WARNING: recreating ${_adm}/sum/tacct " >> ${_active} - nulladm sum/tacct -fi - -# "merge in todays tacct with the summary tacct" -rm -f sum/tacctprev -cp sum/tacct sum/tacctprev -acctmerg sum/tacctprev < sum/tacct${_date} > sum/tacct - -echo "updated sum/tacct" >> ${_active} -echo "CMS" > ${_statefile} -;; - - -CMS) -cd ${_adm}/acct -# "do command summaries" -nulladm sum/daycms -if test ! -r sum/cms; then - nulladm sum/cms - echo "WARNING: recreating ${_adm}/sum/cms " >> ${_active} -fi -cp sum/cms sum/cmsprev -acctcms ${_adm}/Spacct*.${_date} > sum/daycms -acctcms -s sum/daycms sum/cmsprev > sum/cms -acctcms -a -s sum/daycms | sed -n 1,56p > nite/daycms -acctcms -a -s sum/cms | sed -n 1,56p > nite/cms -lastlogin -echo "command summaries complete" >> ${_active} -echo "USEREXIT" > ${_statefile} -;; - - -USEREXIT) -# "any installation dependant accounting programs should be run here" -[ -s /usr/lib/acct/runacct.local ] && /usr/lib/acct/runacct.local - -echo "CLEANUP" > ${_statefile} -;; - - -CLEANUP) -cd ${_adm}/acct -# " finally clear files; could be done next morning if desired" -nulladm ${_adm}/fee -rm -f ${_adm}/Spacct*.${_date} -# "put reports onto a file" -prdaily >> sum/rprt${_date}; -rm -f nite/lock* -rm -f nite/ptacct*.${_date} nite/ctacct.${_date} -mv -f nite/${_date}.wtmpx nite/owtmpx -rm -f nite/wtmperror${_date} nite/active${_date} nite/tmpwtmp -echo "system accounting completed at `date`" >> ${_active} -echo "********** SYSTEM ACCOUNTING COMPLETED `date` **********" | logger -p daemon.notice -echo "COMPLETE" > ${_statefile} -exit 0 -;; - -*) - (date;echo "${_errormsg}") | logger -p daemon.err - echo "${_errormsg}" | mailx adm root - echo "ERROR: invalid state, check ${_statefile}" >> active - rm -f ${_nite}/lock* - mv ${_active} ${_active}${_date} - exit 1 - ;; -esac -done - - -# " runacct is normally called with no arguments from the cron" -# " it checks its own locks to make sure that 2 crons or previous" -# " problems have not occured" - -# " runacct uses the statefile to record its progress" -# " each state updates the statefile upon completion" -# " then the next loop though the while picks up the new state" - -# " to restart this shell, check the active file for diagnostics" -# " fix up any corrupted data (ie. bad pacct or wtmpx files)" -# " if runacct detected the error it removes the locks" -# " remove the locks if necessary, otherwise runacct will complain" -# " the lastdate file should be removed or changed" -# " restart runacct at current state with: runacct MMDD" -# " to override the statefile: runacct MMDD STATE" - - -# " if runacct has been executed after the latest failure" -# " ie. it ran ok today but failed yesterday" -# " the statefile will not be correct" -# " check the active files and restart properly" - -# " if runacct failed in the PROCESS state, remove the last" -# " ptacct file because it may not be complete" - -# " if shell has failed several days, do SETUP manually" -# " then rerun runacct once for each day failed" -# " could use fwtmp here to split up wtmpx file correctly" - -# " normally not a good idea to restart the SETUP state" -# " should be done manually, or just cleanup first" - - -# " FILE USAGE: all files in /var/log/acct/nite unless specified" - -# " statefile records progess of runacct" -# " lastdate last day runacct ran in date +%m%d format" -# " lock lock1 controls serial use of runacct" -# " active place for all descriptive and error messages" -# " fd2log fd2 output for runacct ( see cron entry ) " -# " MMDD.wtmpx owtmpx yesterdays wtmpx file" -# " tmpwtmp yesterdays wtmp corrected by wtmpfix" -# " wtmperror place for wtmpfix error messages" -# " lineuse lineusage report used in prdaily" -# " reboots reboots report used in prdaily" -# " log place for error messages from acctcon1" -# " ctacct.MMDD connect tacct records for MMDD" -# " ptacct.n.MMDD process tacct records n files for MMDD" -# " daytacct total tacct records for this days accounting" -# " disktacct disk tacct records produced by disk shell" -# " daycms ascii daily command summary used by prdaily" -# " cms acsii total command summary used by prdaily" - -# " following files in /var/log directory" - -# " fee output from chargefee program" -# " pacct active pacct file" -# " pacctn switched pacct files" -# " Spacctn.MMDD pacct files for MMDD after SETUP state" -# " wtmpx active wtmpx file" - -# " following files in /var/log/acct/sum" - -# " loginlog output of lastlogin used in prdaily" -# " tacct total tacct file for current fiscal" -# " tacct.MMDD tacct file for day MMDD" -# " cms total cms file for current fiscal" -# " rprt.MMDD output of prdaily program" -# " MMDD.wtmpx saved copy of wtmpx for MMDD" -# " pacct.MMDD concatenated version of all pacct files for MMDD" -# " cmsprev total cms file without latest update" -# " tacctprev total tacct file without latest update" -# " daycms cms files for todays usage"
--- a/usr/src/cmd/acct/shutacct.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved -# Copyright (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */ -# "shutacct [arg] - shuts down acct, called from /usr/sbin/shutdown" -# "whenever system taken down" -# "arg added to /var/wtmpx to record reason, defaults to shutdown" -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -_reason=${1-"acctg off"} -acctwtmp "${_reason}" /var/log/wtmpx -turnacct off
--- a/usr/src/cmd/acct/startup.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved -# Copyright (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */ -# "startup (acct) - should be called from /etc/rc" -# "whenever system is brought up" -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -acctwtmp "acctg on" /var/log/wtmpx -turnacct switch -# "clean up yesterdays accounting files" -rm -f /var/log/acct/sum/wtmp* -rm -f /var/log/acct/sum/pacct* -rm -f /var/log/acct/nite/lock*
--- a/usr/src/cmd/acct/turnacct.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright 1991-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. - -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" -# "control process accounting (must be root)" -# "turnacct on makes sure it's on" -# "turnacct off turns it off" -# "turnacct switch switches pacct to pacct?, starts fresh one" -# "/var/log/pacct is always the current pacct file" -PATH=/usr/lib/acct:/usr/bin:/usr/sbin -cd /var/log -case "$1" in -on) - if test ! -r pacct - then - nulladm pacct - fi - accton pacct - _rc=$? - ;; -off) - accton - _rc=$? - ;; -switch) - pfexec /usr/sbin/logadm -p now /var/log/pacct - if test ! -r pacct - then - nulladm pacct - accton pacct - fi - _rc=$? - ;; -*) - echo "Usage: turnacct on|off|switch" >&2 - _rc=1 - ;; -esac -exit ${_rc}
--- a/usr/src/cmd/acct/utmp2wtmp.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * create entries for users who are still logged on when accounting - * is being run. Look at utmpx, and update the time stamp. New info - * goes to wtmpx. Called by runacct. - */ - -#include <stdio.h> -#include <sys/types.h> -#include <utmpx.h> -#include <time.h> -#include <string.h> -#include <errno.h> -#include <stdlib.h> - -int -main(int argc, char **argv) -{ - struct utmpx *utmpx; - FILE *fp; - - fp = fopen(WTMPX_FILE, "a+"); - if (fp == NULL) { - fprintf(stderr, "%s: %s: %s\n", argv[0], - WTMPX_FILE, strerror(errno)); - exit(1); - } - - while ((utmpx = getutxent()) != NULL) { - if ((utmpx->ut_type == USER_PROCESS) && !(nonuserx(*utmpx))) { - time(&utmpx->ut_xtime); - fwrite(utmpx, sizeof (*utmpx), 1, fp); - } - } - fclose(fp); - exit(0); -}
--- a/usr/src/cmd/acct/wtmpfix.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,733 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * wtmpfix - adjust wtmpx file and remove date changes. - * wtmpfix <wtmpx1 >wtmpx2 - * - * Can recover to some extent from wtmpx corruption. - */ - -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/param.h> -#include "acctdef.h" -#include <utmpx.h> -#include <time.h> -#include <ctype.h> -#include <locale.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> - -#define DAYEPOCH (60 * 60 * 24) -#define UTRSZ (sizeof (struct futmpx)) /* file record size */ - -/* - * The acctsh(8) shell scripts startup(8) and shutacct(8) as well as the - * runacct script each pass their own specific reason strings in the first - * argument to acctwtmp(8), to be propagated into ut_line fields. Additional - * reasons (RUNLVL_MSG, ..., DOWN_MSG), used by compiled code, are defined in - * <utmp.h> as preprocessor constants. - * For simplicity we predefine similar constants for the scripted strings - * here, as no other compiled code uses those. - * Moreover, we need a variant of RUNLVL_MSG without the "%c" at the end. - * We shall use the fact that ut_line[RLVLMSG_LEN] will extract the char - * in the %c position ('S', '2', ...). - * Since all of these string constants are '\0' terminated, they can safely - * be used with strcmp() even when ut_line is not. - */ -#define RUN_LEVEL_MSG "run-level " -#define ACCTG_ON_MSG "acctg on" -#define ACCTG_OFF_MSG "acctg off" -#define RUNACCT_MSG "runacct" - -#define RLVLMSG_LEN (sizeof (RUN_LEVEL_MSG) - 1) - -/* - * Records encountered are classified as one of the following: corrupted; - * ok but devoid of interest to acctcon downstream; ok and interesting; - * or ok and even redundant enough to latch onto a new alignment whilst - * recovering from a corruption. - * The ordering among these four symbolic values is significant. - */ -typedef enum { - INRANGE_ERR = -1, - INRANGE_DROP, - INRANGE_PASS, - INRANGE_ALIGNED -} inrange_t; - -/* input filenames and record numbers, for diagnostics only */ -#define STDIN_NAME "<stdin>" -static char *cur_input_name; -static off_t recin; - -static FILE *Wtmpx, *Temp; - -struct dtab -{ - off_t d_off1; /* file offset start */ - off_t d_off2; /* file offset stop */ - time_t d_adj; /* time adjustment */ - struct dtab *d_ndp; /* next record */ -}; - -static struct dtab *Fdp; /* list header */ -static struct dtab *Ldp; /* list trailer */ - -static time_t lastmonth, nextmonth; - -static struct futmpx Ut, Ut2; - -static int winp(FILE *, struct futmpx *); -static void mkdtab(off_t); -static void setdtab(off_t, struct futmpx *, struct futmpx *); -static void adjust(off_t, struct futmpx *); -static int invalid(char *); -static void scanfile(void); -static inrange_t inrange(void); -static void wcomplain(char *); - -int -main(int argc, char **argv) -{ - time_t tloc; - struct tm *tmp; - int year; - int month; - off_t rectmpin; - - (void) setlocale(LC_ALL, ""); - setbuf(stdout, NULL); - - (void) time(&tloc); - tmp = localtime(&tloc); - year = tmp->tm_year; - month = tmp->tm_mon + 1; - lastmonth = ((year + 1900 - 1970) * 365 + - (month - 1) * 30) * DAYEPOCH; - nextmonth = ((year + 1900 - 1970) * 365 + - (month + 1) * 30) * DAYEPOCH; - - if (argc < 2) { - argv[argc] = "-"; - argc++; - } - - /* - * Almost all system call failures in this program are unrecoverable - * and therefore fatal. Typical causes might be lack of memory or - * of space in a filesystem. If necessary, the system administrator - * can invoke /usr/lib/acct/runacct interactively after making room - * to complete the remaining phases of last night's accounting. - */ - if ((Temp = tmpfile()) == NULL) { - perror("Cannot create temporary file"); - return (EXIT_FAILURE); - } - - while (--argc > 0) { - argv++; - if (strcmp(*argv, "-") == 0) { - Wtmpx = stdin; - cur_input_name = STDIN_NAME; - } else if ((Wtmpx = fopen(*argv, "r")) == NULL) { - (void) fprintf(stderr, "Cannot open %s: %s\n", - *argv, strerror(errno)); - return (EXIT_FAILURE); - } else { - cur_input_name = *argv; - } - /* - * Filter records reading from current input stream Wtmpx, - * writing to Temp. - */ - scanfile(); - - if (Wtmpx != stdin) - (void) fclose(Wtmpx); - } - /* flush and rewind Temp for readback */ - if (fflush(Temp) != 0) { - perror("<temporary file>: fflush"); - return (EXIT_FAILURE); - } - if (fseeko(Temp, (off_t)0L, SEEK_SET) != 0) { - perror("<temporary file>: seek"); - return (EXIT_FAILURE); - } - /* second pass: apply time adjustments */ - rectmpin = 0; - while (winp(Temp, &Ut)) { - adjust(rectmpin, &Ut); - rectmpin += UTRSZ; - if (fwrite(&Ut, UTRSZ, 1, stdout) < 1) { - perror("<stdout>: fwrite"); - return (EXIT_FAILURE); - } - } - (void) fclose(Temp); - /* - * Detect if we've run out of space (say) and exit unsuccessfully - * so that downstream accounting utilities won't start processing an - * incomplete tmpwtmp file. - */ - if (fflush(stdout) != 0) { - perror("<stdout>: fflush"); - return (EXIT_FAILURE); - } - return (EXIT_SUCCESS); -} - -static int -winp(FILE *f, struct futmpx *w) -{ - if (fread(w, (size_t)UTRSZ, (size_t)1, f) != 1) - return (0); - if ((w->ut_type >= EMPTY) && (w->ut_type <= UTMAXTYPE)) - return (1); - else { - (void) fprintf(stderr, "Bad temp file at offset %lld\n", - (longlong_t)(ftell(f) - UTRSZ)); - /* - * If input was corrupt, neither ut_line nor ut_user can be - * relied on to be \0-terminated. Even fixing the precision - * does not entirely guard against this. - */ - (void) fprintf(stderr, - "ut_line \"%-12.12s\" ut_user \"%-8.8s\" ut_xtime %ld\n", - w->ut_line, w->ut_user, (long)w->ut_xtime); - exit(EXIT_FAILURE); - } - /* NOTREACHED */ -} - -static void -mkdtab(off_t p) -{ - - struct dtab *dp; - - dp = Ldp; - if (dp == NULL) { - dp = calloc(sizeof (struct dtab), 1); - if (dp == NULL) { - (void) fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - Fdp = Ldp = dp; - } - dp->d_off1 = p; -} - -static void -setdtab(off_t p, struct futmpx *w1, struct futmpx *w2) -{ - struct dtab *dp; - - if ((dp = Ldp) == NULL) { - (void) fprintf(stderr, "no dtab\n"); - exit(EXIT_FAILURE); - } - dp->d_off2 = p; - dp->d_adj = w2->ut_xtime - w1->ut_xtime; - if ((Ldp = calloc(sizeof (struct dtab), 1)) == NULL) { - (void) fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - Ldp->d_off1 = dp->d_off1; - dp->d_ndp = Ldp; -} - -static void -adjust(off_t p, struct futmpx *w) -{ - - off_t pp; - struct dtab *dp; - - pp = p; - - for (dp = Fdp; dp != NULL; dp = dp->d_ndp) { - if (dp->d_adj == 0) - continue; - if (pp >= dp->d_off1 && pp <= dp->d_off2) - w->ut_xtime += dp->d_adj; - } -} - -/* - * invalid() determines whether the name field adheres to the criteria - * set forth in acctcon1. If returns VALID if the name is ok, or - * INVALID if the name violates conventions. - */ - -static int -invalid(char *name) -{ - int i; - - for (i = 0; i < NSZ; i++) { - if (name[i] == '\0') - return (VALID); - if (! (isalnum(name[i]) || (name[i] == '$') || - (name[i] == ' ') || (name[i] == '.') || - (name[i] == '_') || (name[i] == '-'))) { - return (INVALID); - } - } - return (VALID); -} - -/* - * scanfile: - * 1) reads the current input file - * 2) filters for process records in time range of interest and for - * other types of records deemed interesting to acctcon downstream - * 3) picks up time changes with setdtab() if in multiuser mode, which - * will be applied when the temp file is read back - * 4) changes bad login names to INVALID - * 5) recovers from common cases of wtmpx corruption (loss of record - * alignment). - * All of the static globals are used directly or indirectly. - * - * When wtmpfix is asked to process several input files in succession, - * some state needs to be preserved from one scanfile() invocation to the - * next. Aside from the temp file position, we remember whether we were - * in multi-user mode or not. Absent evidence to the contrary, we begin - * processing assuming multi-user mode, because runacct's wtmpx rotation - * normally gives us a file recently initialized by utmp2wtmp(8) with no - * older RUN_LVL records surviving. - */ - -static void -scanfile() -{ - struct stat Wtstat; - off_t residue = 0; /* input file size mod UTRSZ */ - /* - * lastok will be the offset of the beginning of the most recent - * manifestly plausible and interesting input record in the current - * input file, if any. - * An invariant at loop entry is -UTRSZ <= lastok <= recin - UTRSZ. - */ - off_t lastok = -(off_t)UTRSZ; - static off_t rectmp; /* current temp file position */ - static boolean_t multimode = B_TRUE; /* multi-user RUN_LVL in force */ - inrange_t is_ok; /* caches inrange() result */ - /* - * During normal operation, records are of interest and copied to - * the output when is_ok >= INRANGE_PASS, ignored and dropped when - * is_ok == INRANGE_DROP, and evidence of corruption otherwise. - * While we are trying to recover from a corruption and hunting for - * records with sufficient redundancy to confirm that we have reached - * proper alignment again, we'll want is_ok >= INRANGE_ALIGNED. - * The value of want_ok is the minimum inrange() result of current - * interest. It is raised to INRANGE_ALIGNED during ongoing recovery - * and dropped back to INRANGE_PASS when we have recovered alignment. - */ - inrange_t want_ok = INRANGE_PASS; - boolean_t recovered = B_FALSE; /* true after a successful recovery */ - int n; - - if (fstat(fileno(Wtmpx), &Wtstat) == -1) { - (void) fprintf(stderr, - "Cannot stat %s (will read sequentially): %s\n", - cur_input_name, strerror(errno)); - } else if ((Wtstat.st_mode & S_IFMT) == S_IFREG) { - residue = Wtstat.st_size % UTRSZ; - } - - /* if residue != 0, part of the file may be misaligned */ - for (recin = 0; - ((n = fread(&Ut, (size_t)UTRSZ, (size_t)1, Wtmpx)) > 0) || - (residue > 0); - recin += UTRSZ) { - if (n == 0) { - /* - * Implying residue > 0 and want_ok == INRANGE_PASS. - * It isn't worth telling an I/O error from EOF here. - * But one case is worth catching to avoid issuing a - * confusing message below. When the previous record - * had been ok, we just drop the current truncated - * record and bail out of the loop -- no seeking back. - */ - if (lastok == recin - UTRSZ) { - wcomplain("file ends in mid-record, " - "final partial record dropped"); - break; - } else { - wcomplain("file ends in mid-record"); - /* handled below like a corrupted record */ - is_ok = INRANGE_ERR; - } - } else - is_ok = inrange(); - - /* alignment recovery logic */ - if ((residue > 0) && (is_ok == INRANGE_ERR)) { - /* - * "Let's go back to the last place where we knew - * where we were..." - * In fact, if the last record had been fine and we - * know there's at least one whole record ahead, we - * might move forward here (by residue bytes, less - * than one record's worth). In any case, we align - * ourselves to an integral number of records before - * the end of the file. - */ - wcomplain("suspecting misaligned records, " - "repositioning"); - recin = lastok + UTRSZ + residue; - residue = 0; - if (fseeko(Wtmpx, recin, SEEK_SET) != 0) { - (void) fprintf(stderr, "%s: seek: %s\n", - cur_input_name, strerror(errno)); - exit(EXIT_FAILURE); - } - wcomplain("starting re-scan"); - /* - * While want_ok is elevated, only unequivocal records - * with inrange() == INRANGE_ALIGNED will be admitted - * to latch onto the tentative new alignment. - */ - want_ok = INRANGE_ALIGNED; - /* - * Compensate for the loop continuation. Doing - * it this way gets the correct offset reported - * in the re-scan message above. - */ - recin -= UTRSZ; - continue; - } - /* assert: residue == 0 or is_ok >= INRANGE_DROP here */ - if (is_ok < want_ok) - /* record of no further interest */ - continue; - if (want_ok == INRANGE_ALIGNED) { - wcomplain("now recognizing aligned records again"); - want_ok = INRANGE_PASS; - recovered = B_TRUE; - } - /* - * lastok must track recin whenever the current record is - * being processed and written out to our temp file, to avoid - * reprocessing any bits already done when we readjust our - * alignment. - */ - lastok = recin; - - /* now we have a good wtmpx record, do more processing */ - - if (rectmp == 0 || Ut.ut_type == BOOT_TIME) - mkdtab(rectmp); - if (Ut.ut_type == RUN_LVL) { - /* inrange() already checked the "run-level " part */ - if (Ut.ut_line[RLVLMSG_LEN] == 'S') - multimode = B_FALSE; - else if ((Ut.ut_line[RLVLMSG_LEN] == '2') || - (Ut.ut_line[RLVLMSG_LEN] == '3') || - (Ut.ut_line[RLVLMSG_LEN] == '4')) - multimode = B_TRUE; - } - if (invalid(Ut.ut_name) == INVALID) { - (void) fprintf(stderr, - "wtmpfix: logname \"%*.*s\" changed " - "to \"INVALID\"\n", OUTPUT_NSZ, - OUTPUT_NSZ, Ut.ut_name); - (void) strncpy(Ut.ut_name, "INVALID", NSZ); - } - /* - * Special case: OLD_TIME should be immediately followed by - * NEW_TIME. - * We make no attempt at alignment recovery between these - * two: if there's junk at this point in the input, then - * a NEW_TIME seen after the junk probably won't be the one - * we are looking for. - */ - if (Ut.ut_type == OLD_TIME) { - /* - * Make recin refer to the expected NEW_TIME. - * Loop continuation will increment it again - * for the record we're about to read now. - */ - recin += UTRSZ; - if (!fread(&Ut2, (size_t)UTRSZ, (size_t)1, Wtmpx)) { - wcomplain("input truncated after OLD_TIME - " - "giving up"); - exit(EXIT_FAILURE); - } - /* - * Rudimentary NEW_TIME sanity check. Not as thorough - * as in inrange(), but then we have redundancy from - * context here, since we're just after a plausible - * OLD_TIME record. - */ - if ((Ut2.ut_type != NEW_TIME) || - (strcmp(Ut2.ut_line, NTIME_MSG) != 0)) { - wcomplain("NEW_TIME expected but missing " - "after OLD_TIME - giving up"); - exit(EXIT_FAILURE); - } - lastok = recin; - if (multimode == B_TRUE) - setdtab(rectmp, &Ut, &Ut2); - rectmp += 2 * UTRSZ; - if ((fwrite(&Ut, UTRSZ, 1, Temp) < 1) || - (fwrite(&Ut2, UTRSZ, 1, Temp) < 1)) { - perror("<temporary file>: fwrite"); - exit(EXIT_FAILURE); - } - continue; - } - if (fwrite(&Ut, UTRSZ, 1, Temp) < 1) { - perror("<temporary file>: fwrite"); - exit(EXIT_FAILURE); - } - rectmp += UTRSZ; - } - if (want_ok == INRANGE_ALIGNED) { - wcomplain("EOF reached without recognizing another aligned " - "record with certainty. This file may need to be " - "repaired by hand.\n"); - } else if (recovered == B_TRUE) { - /* - * There may have been a number of wcomplain() messages - * since we reported about the re-scan, so it bears repeating - * at the end that not all was well. - */ - wcomplain("EOF reached after recovering from corruption " - "in the middle of the file. This file may need to be " - "repaired by hand.\n"); - } -} - -/* - * inrange: inspect what we hope to be one wtmpx record. - * Globals: Ut, lastmonth, nextmonth; recin, cur_input_name (diagnostics) - * Return values: - * INRANGE_ERR -- an inconsistency was detected, input file corrupted - * INRANGE_DROP -- Ut appears consistent but isn't of interest - * (of process type and outside the time range we want) - * INRANGE_PASS -- Ut appears consistent and this record is of interest - * INRANGE_ALIGNED -- same, and it is also redundant enough to be sure - * that we're correctly aligned on record boundaries - */ -#define UNEXPECTED_UT_PID \ - (Ut.ut_pid != 0) || \ - (Ut.ut_exit.e_termination != 0) || \ - (Ut.ut_exit.e_exit != 0) - -static inrange_t -inrange() -{ - /* pid_t is signed so that fork() can return -1. Exploit this. */ - if (Ut.ut_pid < 0) { - wcomplain("negative pid"); - return (INRANGE_ERR); - } - - /* the legal values for ut_type are enumerated in <utmp.h> */ - switch (Ut.ut_type) { - case EMPTY: - if (UNEXPECTED_UT_PID) { - wcomplain("nonzero pid or status in EMPTY record"); - return (INRANGE_ERR); - } - /* - * We'd like to have Ut.ut_user[0] == '\0' here, but sadly - * this isn't always so, so we can't rely on it. - */ - return (INRANGE_DROP); - case RUN_LVL: - /* ut_line must have come from the RUNLVL_MSG pattern */ - if (strncmp(Ut.ut_line, RUN_LEVEL_MSG, RLVLMSG_LEN) != 0) { - wcomplain("RUN_LVL record doesn't say `" - RUN_LEVEL_MSG "'"); - return (INRANGE_ERR); - } - /* - * The ut_pid, termination, and exit status fields have - * special meaning in this case, and none of them is - * suitable for checking. And we won't insist on ut_user - * to always be an empty string. - */ - return (INRANGE_ALIGNED); - case BOOT_TIME: - if (UNEXPECTED_UT_PID) { - wcomplain("nonzero pid or status in BOOT_TIME record"); - return (INRANGE_ERR); - } - if (strcmp(Ut.ut_line, BOOT_MSG) != 0) { - wcomplain("BOOT_TIME record doesn't say `" - BOOT_MSG "'"); - return (INRANGE_ERR); - } - return (INRANGE_ALIGNED); - case OLD_TIME: - if (UNEXPECTED_UT_PID) { - wcomplain("nonzero pid or status in OLD_TIME record"); - return (INRANGE_ERR); - } - if (strcmp(Ut.ut_line, OTIME_MSG) != 0) { - wcomplain("OLD_TIME record doesn't say `" - OTIME_MSG "'"); - return (INRANGE_ERR); - } - return (INRANGE_ALIGNED); - case NEW_TIME: - /* - * We don't actually expect to see any here. If they follow - * an OLD_TIME record as they should, they'll be handled on - * the fly in scanfile(). But we might still run into one - * if the input is somehow corrupted. - */ - if (UNEXPECTED_UT_PID) { - wcomplain("nonzero pid or status in NEW_TIME record"); - return (INRANGE_ERR); - } - if (strcmp(Ut.ut_line, NTIME_MSG) != 0) { - wcomplain("NEW_TIME record doesn't say `" - NTIME_MSG "'"); - return (INRANGE_ERR); - } - return (INRANGE_ALIGNED); - - /* the four *_PROCESS ut_types have a lot in common */ - case USER_PROCESS: - /* - * Catch two special cases first: psradm records have no id - * and no pid, while root login over FTP may not have a - * valid ut_user and may have garbage in ut_id[3]. - */ - if ((strcmp(Ut.ut_user, "psradm") == 0) && - (Ut.ut_id[0] == '\0') && - (Ut.ut_pid > 0)) { - if ((Ut.ut_xtime > lastmonth) && - (Ut.ut_xtime < nextmonth)) { - return (INRANGE_ALIGNED); - } else { - return (INRANGE_DROP); - } - } - if ((Ut.ut_user[0] == '\0') && - (strncmp(Ut.ut_id, "ftp", 3) == 0) && - (strncmp(Ut.ut_line, "ftp", 3) == 0)) { - if ((Ut.ut_xtime > lastmonth) && - (Ut.ut_xtime < nextmonth)) { - return (INRANGE_ALIGNED); - } else { - return (INRANGE_DROP); - } - } - /* FALLTHROUGH */ - case LOGIN_PROCESS: - if (Ut.ut_user[0] == '\0') { - wcomplain("missing username in process record"); - return (INRANGE_ERR); - } - /* FALLTHROUGH */ - case INIT_PROCESS: - /* - * INIT_PROCESS and DEAD_PROCESS records can come with an - * empty ut_user in degenerate cases (e.g. syntax errors - * like a comment-only process field in /etc/inittab). - * But in an INIT_PROCESS, LOGIN_PROCESS, or USER_PROCESS - * record, we expect a respectable ut_pid. - */ - if (Ut.ut_pid == 0) { - wcomplain("null pid in process record"); - return (INRANGE_ERR); - } - /* FALLTHROUGH */ - case DEAD_PROCESS: - /* - * DEAD_PROCESS records with a null ut_pid can be produced - * by gnome-terminal (normally seen in utmpx only, but they - * can leak into wtmpx in rare circumstances). - * Unfortunately, ut_id can't be relied on to contain - * anything in particular. (E.g., sshd might leave it - * 0-initialized.) This leaves almost no verifiable - * redundancy here beyond the ut_type. - * At least we insist on a reasonable timestamp. - */ - if (Ut.ut_xtime <= 0) { - wcomplain("non-positive time in process record"); - return (INRANGE_ERR); - } - if ((Ut.ut_xtime > lastmonth) && - (Ut.ut_xtime < nextmonth)) { - return (INRANGE_PASS); - } else { - return (INRANGE_DROP); - } - case ACCOUNTING: - /* - * If we recognize one of the three reason strings passed - * by the /usr/lib/acct shell scripts to acctwtmp, we - * exploit the available redundancy they offer. But - * acctwtmp could have been invoked by custom scripts or - * interactively with other reason strings in the first - * argument, so anything we don't recognize does not - * constitute evidence for corruption. - */ - if ((strcmp(Ut.ut_line, RUNACCT_MSG) != 0) && - (strcmp(Ut.ut_line, ACCTG_ON_MSG) != 0) && - (strcmp(Ut.ut_line, ACCTG_OFF_MSG) != 0)) { - return (INRANGE_DROP); - } - return (INRANGE_ALIGNED); - case DOWN_TIME: - if (UNEXPECTED_UT_PID) { - wcomplain("nonzero pid or status in DOWN_TIME record"); - return (INRANGE_ERR); - } - if (strcmp(Ut.ut_line, DOWN_MSG) != 0) { - wcomplain("DOWN_TIME record doesn't say `" - DOWN_MSG "'"); - return (INRANGE_ERR); - } - return (INRANGE_ALIGNED); - default: - wcomplain("ut_type out of range"); - return (INRANGE_ERR); - } - /* NOTREACHED */ -} - -static void -wcomplain(char *msg) -{ - (void) fprintf(stderr, "%s: offset %lld: %s\n", cur_input_name, - (longlong_t)recin, msg); -}
--- a/usr/src/cmd/sa/Makefile Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# Copyright (c) 2013 Andrew Stormont. All rights reserved. -# -# Copyright (c) 2018, Joyent, Inc. - -MANIFEST = sar.xml -SVCMETHOD = svc-sar - -include ../Makefile.cmd - -ROOTMANIFESTDIR = $(ROOTSVCSYSTEM) - -CERRWARN += -Wno-parentheses -CERRWARN += -Wno-uninitialized - -SMOFF += all_func_returns - -GREP= grep - -SADC= sadc -SAR= sar -TIMEX= timex -SA1= sa1 -SA2= sa2 - -sadc := LDLIBS += -lkstat - -# Executables produced -BINPROG= $(TIMEX) -SBINPROG= $(SAR) -LIBPROG= $(SADC) -LIBSHELL= $(SA1) $(SA2) -INITSHELL= $(PERF) - -PROGS= $(BINPROG) $(SBINPROG) $(LIBPROG) -SHELLS= $(LIBSHELL) -TXTS= README -ALL= $(PROGS) $(SHELLS) - -# Source files -SADC_OBJECTS= $(SADC).o -srcs= $(TIMEX) $(SAR) $(SADC) -SRCS= $(srcs:%=%.c) -SHSRCS= $(SHELLS:%=%.sh) - -# Set of target install directories -LIBSAD= $(ROOT)/usr/lib/sa -CROND= $(ROOT)/var/spool/cron -CRONTABSD= $(CROND)/crontabs - -# Set of target install files -SYSCRONTAB= $(CRONTABSD)/sys -ROOTPROG= $(BINPROG:%=$(ROOTBIN)/%) -ROOTUSBINPROG= $(SBINPROG:%=$(ROOTUSRSBIN)/%) -ROOTLIBPROG= $(LIBPROG:%=$(LIBSAD)/%) -ROOTLIBSHELL= $(LIBSHELL:%=$(LIBSAD)/%) -ROOTSYMLINKS= $(SBINPROG:%=$(ROOTBIN)/%) - -# Performance monitoring should not be enabled by default. Hence, these -# entries are comments. -ENTRY1= '$(POUND_SIGN) 0 * * * 0-6 /usr/lib/sa/sa1' -ENTRY2= '$(POUND_SIGN) 20,40 8-17 * * 1-5 /usr/lib/sa/sa1' -ENTRY3= '$(POUND_SIGN) 5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A' - -CLOBBERFILES= $(PROGS) $(SHELLS) - -# Conditionals -$(LIBSAD)/$(SADC) := FILEMODE = 0555 - -.KEEP_STATE: - -all: $(ALL) $(TXTS) - -$(SADC): $(SADC_OBJECTS) - $(LINK.c) -o $@ $(SADC_OBJECTS) $(LDLIBS) - $(POST_PROCESS) - -# The edit of SYSCRONTAB must be done unconditionally because of the -# creation of this file by a different component (Adm) and the possible -# backdating. -install: all $(ROOTPROG) $(ROOTUSBINPROG) \ - $(ROOTINITSHELL) $(ROOTLIBSHELL) $(ROOTSYMLINKS) \ - $(ROOTMANIFEST) $(ROOTSVCMETHOD) $(ROOTLIBPROG) - @if [ -f $(SYSCRONTAB) ]; \ - then \ - if $(GREP) "sa1" $(SYSCRONTAB) >/dev/null 2>&1 ; then :; \ - else \ - echo $(ENTRY1) >> $(SYSCRONTAB); \ - echo $(ENTRY2) >> $(SYSCRONTAB); \ - echo "$(SYSCRONTAB) modified"; \ - fi; \ - if $(GREP) "sa2" $(SYSCRONTAB) >/dev/null 2>&1 ; then :; \ - else \ - echo $(ENTRY3) >> $(SYSCRONTAB); \ - fi; \ - fi - -$(LIBSAD)/%: % - $(INS.file) - -$(ROOTSYMLINKS): - -$(RM) $@; $(SYMLINK) ../sbin/`basename $@` $@ - -$(ETCINITD)/%: % - $(INS.file) - -check: $(CHKMANIFEST) - -clean: - $(RM) $(SADC_OBJECTS) $(PROGS) $(SHELLS) - - -include ../Makefile.targ
--- a/usr/src/cmd/sa/README Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - - Copyright 2004 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - -ident "%Z%%M% %I% %E% SMI" - -README 1.9 of 5/8/89 - -Instruction of daily report generation: - -1. The line - - /usr/lib/sa/sadc /var/log/sa/sa`date +%d` - - is executed by the start method for the system/sar:default service, - if enabled - - sadc is executed once, such that a special record is written to - the daily data file when UNIX restarts. - -2. The execution of shell script - sa1 [t n] - causes data collection program to write system activity - counters n times at every t-second interval on data file. - If t and n are not specified, it writes data once. - According to your installation's requirement, enter - entries of executing sa1 [t n] in /var/spool/cron/crontabs/sys - to collect system activity data. - For example, entries - - 0 8-17 * * 1-5 su sys -c "/usr/lib/sa/sa1 1200 3 &" and - 0 18-23 * * 1-5 su sys -c "/usr/lib/sa/sa1 &" - - cause data collection program to be activated at every hour - on the hour from 8:00 to 23:00 on weekdays. - Moreover, It writes data on data file 3 times at every 20 - minutes interval from 8:00 to 17:00 and once at other times. - -3. Shell procedure sa2 will invoke sar command to generate - the daily report from the data file. Its usage is - - sa2 [-options] [-s hh:mm] [-e hh:mm] [-i ss] - - where -s and -e specify the report starting and ending times - respectively, -i specifies the report data interval in seconds. - If they are not specified, all data from the data file are to - be reported. -options are report options, see manual page - sar.1 for description. - - Make an entry to execute sa2 in /var/spool/cron/crontabs. - For instance, entry - - 5 18 * * 1-5 su adm -c "/usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 3600 - -ubd &" - - causes the invocation of sar command at 18:05. It generates - the daily report that includes the hourly cpu utilization, - buffer usage and disk and tape activities from 8:00 to 18:01.
--- a/usr/src/cmd/sa/sa.h Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,224 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SA_H -#define _SA_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * sa.h contains struct sa and defines variables used in sadc.c and sar.c. - * RESTRICTION: the data types defined in this file must not be changed. - * sar writes these types to disk as binary data and to ensure version to - * version compatibility they must not be changed. - */ - -#include <sys/kstat.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct iodevinfo { - struct iodevinfo *next; - kstat_t *ksp; - kstat_t ks; - kstat_io_t kios; -} iodevinfo_t; - -#define KMEM_SMALL 0 /* small KMEM request index */ -#define KMEM_LARGE 1 /* large KMEM request index */ -#define KMEM_OSIZE 2 /* outsize KMEM request index */ -#define KMEM_NCLASS 3 /* # of KMEM request classes */ - -typedef struct kmeminfo { - ulong_t km_mem[KMEM_NCLASS]; /* amount of mem owned by KMEM */ - ulong_t km_alloc[KMEM_NCLASS]; /* amount of mem allocated */ - ulong_t km_fail[KMEM_NCLASS]; /* # of failed requests */ -} kmeminfo_t; - -/* - * structure sa defines the data structure of system activity data file - */ - -struct sa { - int valid; /* non-zero for valid data */ - time_t ts; /* time stamp */ - - cpu_sysinfo_t csi; /* per-CPU system information */ - cpu_vminfo_t cvmi; /* per-CPU vm information */ - sysinfo_t si; /* global system information */ - vminfo_t vmi; /* global vm information */ - kmeminfo_t kmi; /* kernel mem allocation info */ - - ulong_t szinode; /* inode table size */ - ulong_t szfile; /* file table size */ - ulong_t szproc; /* proc table size */ - ulong_t szlckr; /* file record lock table size */ - - ulong_t mszinode; /* max inode table size */ - ulong_t mszfile; /* max file table size */ - ulong_t mszproc; /* max proc table size */ - ulong_t mszlckr; /* max file rec lock table size */ - - ulong_t niodevs; /* number of I/O devices */ - - /* An array of iodevinfo structs come next in the sadc files */ -}; - -typedef struct cpu64_sysinfo { - uint64_t cpu[CPU_STATES]; - uint64_t wait[W_STATES]; - uint64_t bread; - uint64_t bwrite; - uint64_t lread; - uint64_t lwrite; - uint64_t phread; - uint64_t phwrite; - uint64_t pswitch; - uint64_t trap; - uint64_t intr; - uint64_t syscall; - uint64_t sysread; - uint64_t syswrite; - uint64_t sysfork; - uint64_t sysvfork; - uint64_t sysexec; - uint64_t readch; - uint64_t writech; - uint64_t rcvint; - uint64_t xmtint; - uint64_t mdmint; - uint64_t rawch; - uint64_t canch; - uint64_t outch; - uint64_t msg; - uint64_t sema; - uint64_t namei; - uint64_t ufsiget; - uint64_t ufsdirblk; - uint64_t ufsipage; - uint64_t ufsinopage; - uint64_t inodeovf; - uint64_t fileovf; - uint64_t procovf; - uint64_t intrthread; - uint64_t intrblk; - uint64_t idlethread; - uint64_t inv_swtch; - uint64_t nthreads; - uint64_t cpumigrate; - uint64_t xcalls; - uint64_t mutex_adenters; - uint64_t rw_rdfails; - uint64_t rw_wrfails; - uint64_t modload; - uint64_t modunload; - uint64_t bawrite; - uint64_t rw_enters; - uint64_t win_uo_cnt; - uint64_t win_uu_cnt; - uint64_t win_so_cnt; - uint64_t win_su_cnt; - uint64_t win_suo_cnt; -} cpu64_sysinfo_t; - -typedef struct cpu64_vminfo { - uint64_t pgrec; - uint64_t pgfrec; - uint64_t pgin; - uint64_t pgpgin; - uint64_t pgout; - uint64_t pgpgout; - uint64_t swapin; - uint64_t pgswapin; - uint64_t swapout; - uint64_t pgswapout; - uint64_t zfod; - uint64_t dfree; - uint64_t scan; - uint64_t rev; - uint64_t hat_fault; - uint64_t as_fault; - uint64_t maj_fault; - uint64_t cow_fault; - uint64_t prot_fault; - uint64_t softlock; - uint64_t kernel_asflt; - uint64_t pgrrun; - uint64_t execpgin; - uint64_t execpgout; - uint64_t execfree; - uint64_t anonpgin; - uint64_t anonpgout; - uint64_t anonfree; - uint64_t fspgin; - uint64_t fspgout; - uint64_t fsfree; -} cpu64_vminfo_t; - -typedef struct sysinfo64 { - uint64_t updates; - uint64_t runque; - uint64_t runocc; - uint64_t swpque; - uint64_t swpocc; - uint64_t waiting; -} sysinfo64_t; - -struct sa64 { - int valid; - time_t ts; - - cpu64_sysinfo_t csi; - cpu64_vminfo_t cvmi; - sysinfo64_t si; - vminfo_t vmi; - kmeminfo_t kmi; - - ulong_t szinode; - ulong_t szfile; - ulong_t szproc; - ulong_t szlckr; - - ulong_t mszinode; - ulong_t mszfile; - ulong_t mszproc; - ulong_t mszlckr; - - ulong_t niodevs; -}; - -extern struct sa sa; - -#ifdef __cplusplus -} -#endif - -#endif /* _SA_H */
--- a/usr/src/cmd/sa/sa1.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ -# sa1.sh 1.5 of 5/8/89 -DATE=`/usr/bin/date +%d` -ENDIR=/usr/lib/sa -DFILE=/var/log/sa/sa$DATE -cd $ENDIR -if [ $# = 0 ] -then - exec $ENDIR/sadc 1 1 $DFILE -else - exec $ENDIR/sadc $* $DFILE -fi
--- a/usr/src/cmd/sa/sa2.sh Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */ -# sa2.sh 1.4 of 5/8/89 -DATE=`/usr/bin/date +%d` -RPT=/var/log/sa/sar$DATE -DFILE=/var/log/sa/sa$DATE -ENDIR=/usr/bin -cd $ENDIR -$ENDIR/sar $* -f $DFILE > $RPT -/usr/bin/find /var/log/sa \( -name 'sar*' -o -name 'sa*' \) -mtime +7 -exec /usr/bin/rm {} \;
--- a/usr/src/cmd/sa/sadc.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,807 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -/* - * sadc.c writes system activity binary data to a file or stdout. - * - * Usage: sadc [t n] [file] - * - * if t and n are not specified, it writes a dummy record to data file. This - * usage is particularly used at system booting. If t and n are specified, it - * writes system data n times to file every t seconds. In both cases, if file - * is not specified, it writes data to stdout. - */ - -#include <sys/fcntl.h> -#include <sys/flock.h> -#include <sys/proc.h> -#include <sys/stat.h> -#include <sys/sysinfo.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/var.h> - -#include <ctype.h> -#include <errno.h> -#include <fcntl.h> -#include <kstat.h> -#include <memory.h> -#include <nlist.h> -#include <signal.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <unistd.h> -#include <strings.h> - -#include "sa.h" - -#define MAX(x1, x2) ((x1) >= (x2) ? (x1) : (x2)) - -static kstat_ctl_t *kc; /* libkstat cookie */ -static int ncpus; -static int oncpus; -static kstat_t **cpu_stat_list = NULL; -static kstat_t **ocpu_stat_list = NULL; -static int ncaches; -static kstat_t **kmem_cache_list = NULL; - -static kstat_t *sysinfo_ksp, *vminfo_ksp, *var_ksp; -static kstat_t *system_misc_ksp, *ufs_inode_ksp, *kmem_oversize_ksp; -static kstat_t *file_cache_ksp; -static kstat_named_t *ufs_inode_size_knp, *nproc_knp; -static kstat_named_t *file_total_knp, *file_avail_knp; -static kstat_named_t *oversize_alloc_knp, *oversize_fail_knp; -static int slab_create_index, slab_destroy_index, slab_size_index; -static int buf_size_index, buf_avail_index, alloc_fail_index; - -static struct iodevinfo zeroiodev = { NULL, NULL }; -static struct iodevinfo *firstiodev = NULL; -static struct iodevinfo *lastiodev = NULL; -static struct iodevinfo *snip = NULL; -static ulong_t niodevs; - -static void all_stat_init(void); -static int all_stat_load(void); -static void fail(int, char *, ...); -static void safe_zalloc(void **, int, int); -static kid_t safe_kstat_read(kstat_ctl_t *, kstat_t *, void *); -static kstat_t *safe_kstat_lookup(kstat_ctl_t *, char *, int, char *); -static void *safe_kstat_data_lookup(kstat_t *, char *); -static int safe_kstat_data_index(kstat_t *, char *); -static void init_iodevs(void); -static int iodevinfo_load(void); -static int kstat_copy(const kstat_t *, kstat_t *); -static void diff_two_arrays(kstat_t ** const [], size_t, size_t, - kstat_t ** const []); -static void compute_cpu_stat_adj(void); - -static char *cmdname = "sadc"; - -static struct var var; - -static struct sa d; -static int64_t cpu_stat_adj[CPU_STATES] = {0}; - -static long ninode; - -int caught_cont = 0; - -/* - * Sleep until *wakeup + interval, keeping cadence where desired - * - * *wakeup - The time we last wanted to wake up. Updated. - * interval - We want to sleep until *wakeup + interval - * *caught_cont - Global set by signal handler if we got a SIGCONT - */ -void -sleep_until(hrtime_t *wakeup, hrtime_t interval, int *caught_cont) -{ - hrtime_t now, pause, pause_left; - struct timespec pause_tv; - int status; - now = gethrtime(); - pause = *wakeup + interval - now; - - if (pause <= 0 || pause < (interval / 4)) - if (*caught_cont) { - /* Reset our cadence (see comment below) */ - *wakeup = now + interval; - pause = interval; - } else { - /* - * If we got here, then the time between the - * output we just did, and the scheduled time - * for the next output is < 1/4 of our requested - * interval AND the number of intervals has been - * requested AND we have never caught a SIGCONT - * (so we have never been suspended). In this - * case, we'll try to stay to the desired - * cadence, and we will pause for 1/2 the normal - * interval this time. - */ - pause = interval / 2; - *wakeup += interval; - } - else - *wakeup += interval; - if (pause < 1000) - /* Near enough */ - return; - - /* Now do the actual sleep */ - pause_left = pause; - do { - pause_tv.tv_sec = pause_left / NANOSEC; - pause_tv.tv_nsec = pause_left % NANOSEC; - status = nanosleep(&pause_tv, NULL); - if (status < 0) - if (errno == EINTR) { - now = gethrtime(); - pause_left = *wakeup - now; - if (pause_left < 1000) - /* Near enough */ - return; - } else { - fail(1, "nanosleep failed"); - } - } while (status != 0); -} - -/* - * Signal handler - so we can be aware of SIGCONT - */ -void -cont_handler(int sig_number) -{ - /* Re-set the signal handler */ - (void) signal(sig_number, cont_handler); - caught_cont = 1; -} - -int -main(int argc, char *argv[]) -{ - int ct; - unsigned ti; - int fp; - time_t min; - struct stat buf; - char *fname; - struct iodevinfo *iodev; - off_t flength; - hrtime_t start_n; - hrtime_t period_n; - - - ct = argc >= 3? atoi(argv[2]): 0; - min = time((time_t *)0); - ti = argc >= 3? atoi(argv[1]): 0; - - period_n = (hrtime_t)ti * NANOSEC; - - if ((kc = kstat_open()) == NULL) - fail(1, "kstat_open(): can't open /dev/kstat"); - - /* Set up handler for SIGCONT */ - if (signal(SIGCONT, cont_handler) == SIG_ERR) - fail(1, "signal failed"); - - all_stat_init(); - init_iodevs(); - - if (argc == 3 || argc == 1) { - /* - * no data file is specified, direct data to stdout. - */ - fp = 1; - } else { - struct flock lock; - - fname = (argc == 2) ? argv[1] : argv[3]; - /* - * Open or Create a data file. If the file doesn't exist, then - * it will be created. - */ - if ((fp = open(fname, O_WRONLY | O_APPEND | O_CREAT, 0644)) - == -1) - fail(1, "can't open data file"); - /* - * Lock the entire data file to prevent data corruption - */ - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - lock.l_start = 0; - lock.l_len = 0; - if (fcntl(fp, F_SETLK, &lock) == -1) - fail(1, "can't lock data file"); - /* - * Get data file statistics for use in determining whether - * truncation required and where rollback recovery should - * be applied. - */ - if (fstat(fp, &buf) == -1) - fail(1, "can't get data file information"); - /* - * If the data file was opened and is too old, truncate it - */ - if (min - buf.st_mtime > 86400) - if (ftruncate(fp, 0) == -1) - fail(1, "can't truncate data file"); - /* - * Remember filesize for rollback on error (bug #1223549) - */ - flength = buf.st_size; - } - - memset(&d, 0, sizeof (d)); - - /* - * If n == 0, write the additional dummy record. - */ - if (ct == 0) { - d.valid = 0; - d.ts = min; - d.niodevs = niodevs; - - if (write(fp, &d, sizeof (struct sa)) != sizeof (struct sa)) - ftruncate(fp, flength), fail(1, "write failed"); - - for (iodev = firstiodev; iodev; iodev = iodev->next) { - if (write(fp, iodev, sizeof (struct iodevinfo)) != - sizeof (struct iodevinfo)) - ftruncate(fp, flength), fail(1, "write failed"); - } - } - - start_n = gethrtime(); - - for (;;) { - do { - (void) kstat_chain_update(kc); - all_stat_init(); - init_iodevs(); - } while (all_stat_load() || iodevinfo_load()); - - d.ts = time((time_t *)0); - d.valid = 1; - d.niodevs = niodevs; - - if (write(fp, &d, sizeof (struct sa)) != sizeof (struct sa)) - ftruncate(fp, flength), fail(1, "write failed"); - - for (iodev = firstiodev; iodev; iodev = iodev->next) { - if (write(fp, iodev, sizeof (struct iodevinfo)) != - sizeof (struct iodevinfo)) - ftruncate(fp, flength), fail(1, "write failed"); - } - if (--ct > 0) { - sleep_until(&start_n, period_n, &caught_cont); - } else { - close(fp); - return (0); - } - } - - /*NOTREACHED*/ -} - -/* - * Get various KIDs for subsequent all_stat_load operations. - */ - -static void -all_stat_init(void) -{ - kstat_t *ksp; - - /* - * Initialize global statistics - */ - - sysinfo_ksp = safe_kstat_lookup(kc, "unix", 0, "sysinfo"); - vminfo_ksp = safe_kstat_lookup(kc, "unix", 0, "vminfo"); - kmem_oversize_ksp = safe_kstat_lookup(kc, "vmem", -1, "kmem_oversize"); - var_ksp = safe_kstat_lookup(kc, "unix", 0, "var"); - system_misc_ksp = safe_kstat_lookup(kc, "unix", 0, "system_misc"); - file_cache_ksp = safe_kstat_lookup(kc, "unix", 0, "file_cache"); - ufs_inode_ksp = kstat_lookup(kc, "ufs", 0, "inode_cache"); - - safe_kstat_read(kc, system_misc_ksp, NULL); - nproc_knp = safe_kstat_data_lookup(system_misc_ksp, "nproc"); - - safe_kstat_read(kc, file_cache_ksp, NULL); - file_avail_knp = safe_kstat_data_lookup(file_cache_ksp, "buf_avail"); - file_total_knp = safe_kstat_data_lookup(file_cache_ksp, "buf_total"); - - safe_kstat_read(kc, kmem_oversize_ksp, NULL); - oversize_alloc_knp = safe_kstat_data_lookup(kmem_oversize_ksp, - "mem_total"); - oversize_fail_knp = safe_kstat_data_lookup(kmem_oversize_ksp, "fail"); - - if (ufs_inode_ksp != NULL) { - safe_kstat_read(kc, ufs_inode_ksp, NULL); - ufs_inode_size_knp = safe_kstat_data_lookup(ufs_inode_ksp, - "size"); - ninode = ((kstat_named_t *) - safe_kstat_data_lookup(ufs_inode_ksp, - "maxsize"))->value.l; - } - - /* - * Load constant values now -- no need to reread each time - */ - - safe_kstat_read(kc, var_ksp, (void *) &var); - - /* - * Initialize per-CPU and per-kmem-cache statistics - */ - - ncpus = ncaches = 0; - for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) { - if (strncmp(ksp->ks_name, "cpu_stat", 8) == 0) - ncpus++; - if (strcmp(ksp->ks_class, "kmem_cache") == 0) - ncaches++; - } - - safe_zalloc((void **)&cpu_stat_list, ncpus * sizeof (kstat_t *), 1); - safe_zalloc((void **)&kmem_cache_list, ncaches * sizeof (kstat_t *), 1); - - ncpus = ncaches = 0; - for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) { - if (strncmp(ksp->ks_name, "cpu_stat", 8) == 0 && - kstat_read(kc, ksp, NULL) != -1) - cpu_stat_list[ncpus++] = ksp; - if (strcmp(ksp->ks_class, "kmem_cache") == 0 && - kstat_read(kc, ksp, NULL) != -1) - kmem_cache_list[ncaches++] = ksp; - } - - if (ncpus == 0) - fail(1, "can't find any cpu statistics"); - - if (ncaches == 0) - fail(1, "can't find any kmem_cache statistics"); - - ksp = kmem_cache_list[0]; - safe_kstat_read(kc, ksp, NULL); - buf_size_index = safe_kstat_data_index(ksp, "buf_size"); - slab_create_index = safe_kstat_data_index(ksp, "slab_create"); - slab_destroy_index = safe_kstat_data_index(ksp, "slab_destroy"); - slab_size_index = safe_kstat_data_index(ksp, "slab_size"); - buf_avail_index = safe_kstat_data_index(ksp, "buf_avail"); - alloc_fail_index = safe_kstat_data_index(ksp, "alloc_fail"); -} - -/* - * load statistics, summing across CPUs where needed - */ - -static int -all_stat_load(void) -{ - int i, j; - cpu_stat_t cs; - ulong_t *np, *tp; - uint64_t cpu_tick[4] = {0, 0, 0, 0}; - - memset(&d, 0, sizeof (d)); - - /* - * Global statistics - */ - - safe_kstat_read(kc, sysinfo_ksp, (void *) &d.si); - safe_kstat_read(kc, vminfo_ksp, (void *) &d.vmi); - safe_kstat_read(kc, system_misc_ksp, NULL); - safe_kstat_read(kc, file_cache_ksp, NULL); - - if (ufs_inode_ksp != NULL) { - safe_kstat_read(kc, ufs_inode_ksp, NULL); - d.szinode = ufs_inode_size_knp->value.ul; - } - - d.szfile = file_total_knp->value.ui64 - file_avail_knp->value.ui64; - d.szproc = nproc_knp->value.ul; - - d.mszinode = (ninode > d.szinode) ? ninode : d.szinode; - d.mszfile = d.szfile; - d.mszproc = var.v_proc; - - /* - * Per-CPU statistics. - */ - - for (i = 0; i < ncpus; i++) { - if (kstat_read(kc, cpu_stat_list[i], (void *) &cs) == -1) - return (1); - - np = (ulong_t *)&d.csi; - tp = (ulong_t *)&cs.cpu_sysinfo; - - /* - * Accumulate cpu ticks for CPU_IDLE, CPU_USER, CPU_KERNEL and - * CPU_WAIT with respect to each of the cpus. - */ - for (j = 0; j < CPU_STATES; j++) - cpu_tick[j] += tp[j]; - - for (j = 0; j < sizeof (cpu_sysinfo_t); j += sizeof (ulong_t)) - *np++ += *tp++; - np = (ulong_t *)&d.cvmi; - tp = (ulong_t *)&cs.cpu_vminfo; - for (j = 0; j < sizeof (cpu_vminfo_t); j += sizeof (ulong_t)) - *np++ += *tp++; - } - - /* - * Per-cache kmem statistics. - */ - - for (i = 0; i < ncaches; i++) { - kstat_named_t *knp; - u_longlong_t slab_create, slab_destroy, slab_size, mem_total; - u_longlong_t buf_size, buf_avail, alloc_fail; - int kmi_index; - - if (kstat_read(kc, kmem_cache_list[i], NULL) == -1) - return (1); - knp = kmem_cache_list[i]->ks_data; - slab_create = knp[slab_create_index].value.ui64; - slab_destroy = knp[slab_destroy_index].value.ui64; - slab_size = knp[slab_size_index].value.ui64; - buf_size = knp[buf_size_index].value.ui64; - buf_avail = knp[buf_avail_index].value.ui64; - alloc_fail = knp[alloc_fail_index].value.ui64; - if (buf_size <= 256) - kmi_index = KMEM_SMALL; - else - kmi_index = KMEM_LARGE; - mem_total = (slab_create - slab_destroy) * slab_size; - - d.kmi.km_mem[kmi_index] += (ulong_t)mem_total; - d.kmi.km_alloc[kmi_index] += - (ulong_t)mem_total - buf_size * buf_avail; - d.kmi.km_fail[kmi_index] += (ulong_t)alloc_fail; - } - - safe_kstat_read(kc, kmem_oversize_ksp, NULL); - - d.kmi.km_alloc[KMEM_OSIZE] = d.kmi.km_mem[KMEM_OSIZE] = - oversize_alloc_knp->value.ui64; - d.kmi.km_fail[KMEM_OSIZE] = oversize_fail_knp->value.ui64; - - /* - * Adjust CPU statistics so the delta calculations in sar will - * be correct when facing changes to the set of online CPUs. - */ - compute_cpu_stat_adj(); - for (i = 0; i < CPU_STATES; i++) - d.csi.cpu[i] = (cpu_tick[i] + cpu_stat_adj[i]) / ncpus; - - return (0); -} - -static void -fail(int do_perror, char *message, ...) -{ - va_list args; - - va_start(args, message); - fprintf(stderr, "%s: ", cmdname); - vfprintf(stderr, message, args); - va_end(args); - if (do_perror) - fprintf(stderr, ": %s", strerror(errno)); - fprintf(stderr, "\n"); - exit(2); -} - -static void -safe_zalloc(void **ptr, int size, int free_first) -{ - if (free_first) - free(*ptr); - if ((*ptr = malloc(size)) == NULL) - fail(1, "malloc failed"); - memset(*ptr, 0, size); -} - -static kid_t -safe_kstat_read(kstat_ctl_t *kc, kstat_t *ksp, void *data) -{ - kid_t kstat_chain_id = kstat_read(kc, ksp, data); - - if (kstat_chain_id == -1) - fail(1, "kstat_read(%x, '%s') failed", kc, ksp->ks_name); - return (kstat_chain_id); -} - -static kstat_t * -safe_kstat_lookup(kstat_ctl_t *kc, char *ks_module, int ks_instance, - char *ks_name) -{ - kstat_t *ksp = kstat_lookup(kc, ks_module, ks_instance, ks_name); - - if (ksp == NULL) - fail(0, "kstat_lookup('%s', %d, '%s') failed", - ks_module == NULL ? "" : ks_module, - ks_instance, - ks_name == NULL ? "" : ks_name); - return (ksp); -} - -static void * -safe_kstat_data_lookup(kstat_t *ksp, char *name) -{ - void *fp = kstat_data_lookup(ksp, name); - - if (fp == NULL) - fail(0, "kstat_data_lookup('%s', '%s') failed", - ksp->ks_name, name); - return (fp); -} - -static int -safe_kstat_data_index(kstat_t *ksp, char *name) -{ - return ((int)((char *)safe_kstat_data_lookup(ksp, name) - - (char *)ksp->ks_data) / (ksp->ks_data_size / ksp->ks_ndata)); -} - -static int -kscmp(kstat_t *ks1, kstat_t *ks2) -{ - int cmp; - - cmp = strcmp(ks1->ks_module, ks2->ks_module); - if (cmp != 0) - return (cmp); - cmp = ks1->ks_instance - ks2->ks_instance; - if (cmp != 0) - return (cmp); - return (strcmp(ks1->ks_name, ks2->ks_name)); -} - -static void -init_iodevs(void) -{ - struct iodevinfo *iodev, *previodev, *comp; - kstat_t *ksp; - - iodev = &zeroiodev; - niodevs = 0; - - /* - * Patch the snip in the iodevinfo list (see below) - */ - if (snip) - lastiodev->next = snip; - - for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) { - - if (ksp->ks_type != KSTAT_TYPE_IO) - continue; - previodev = iodev; - if (iodev->next) - iodev = iodev->next; - else { - safe_zalloc((void **) &iodev->next, - sizeof (struct iodevinfo), 0); - iodev = iodev->next; - iodev->next = NULL; - } - iodev->ksp = ksp; - iodev->ks = *ksp; - memset(&iodev->kios, 0, sizeof (kstat_io_t)); - iodev->kios.wlastupdate = iodev->ks.ks_crtime; - iodev->kios.rlastupdate = iodev->ks.ks_crtime; - - /* - * Insertion sort on (ks_module, ks_instance, ks_name) - */ - comp = &zeroiodev; - while (kscmp(&iodev->ks, &comp->next->ks) > 0) - comp = comp->next; - if (previodev != comp) { - previodev->next = iodev->next; - iodev->next = comp->next; - comp->next = iodev; - iodev = previodev; - } - niodevs++; - } - /* - * Put a snip in the linked list of iodevinfos. The idea: - * If there was a state change such that now there are fewer - * iodevs, we snip the list and retain the tail, rather than - * freeing it. At the next state change, we clip the tail back on. - * This prevents a lot of malloc/free activity, and it's simpler. - */ - lastiodev = iodev; - snip = iodev->next; - iodev->next = NULL; - - firstiodev = zeroiodev.next; -} - -static int -iodevinfo_load(void) -{ - struct iodevinfo *iodev; - - for (iodev = firstiodev; iodev; iodev = iodev->next) { - if (kstat_read(kc, iodev->ksp, (void *) &iodev->kios) == -1) - return (1); - } - return (0); -} - -static int -kstat_copy(const kstat_t *src, kstat_t *dst) -{ - *dst = *src; - - if (src->ks_data != NULL) { - if ((dst->ks_data = malloc(src->ks_data_size)) == NULL) - return (-1); - bcopy(src->ks_data, dst->ks_data, src->ks_data_size); - } else { - dst->ks_data = NULL; - dst->ks_data_size = 0; - } - return (0); -} - -/* - * Determine what is different between two sets of kstats; s[0] and s[1] - * are arrays of kstats of size ns0 and ns1, respectively, and sorted by - * instance number. u[0] and u[1] are two arrays which must be - * caller-zallocated; each must be of size MAX(ns0, ns1). When the - * function terminates, u[0] contains all s[0]-unique items and u[1] - * contains all s[1]-unique items. Any unused entries in u[0] and u[1] - * are left NULL. - */ -static void -diff_two_arrays(kstat_t ** const s[], size_t ns0, size_t ns1, - kstat_t ** const u[]) -{ - kstat_t **s0p = s[0], **s1p = s[1]; - kstat_t **u0p = u[0], **u1p = u[1]; - int i = 0, j = 0; - - while (i < ns0 && j < ns1) { - if ((*s0p)->ks_instance == (*s1p)->ks_instance) { - if ((*s0p)->ks_kid != (*s1p)->ks_kid) { - /* - * The instance is the same, but this - * CPU has been offline during the - * interval, so we consider *u0p to - * be s0p-unique, and similarly for - * *u1p. - */ - *(u0p++) = *s0p; - *(u1p++) = *s1p; - } - s0p++; - i++; - s1p++; - j++; - } else if ((*s0p)->ks_instance < (*s1p)->ks_instance) { - *(u0p++) = *(s0p++); - i++; - } else { - *(u1p++) = *(s1p++); - j++; - } - } - - while (i < ns0) { - *(u0p++) = *(s0p++); - i++; - } - while (j < ns1) { - *(u1p++) = *(s1p++); - j++; - } -} - -static int -cpuid_compare(const void *p1, const void *p2) -{ - return ((*(kstat_t **)p1)->ks_instance - - (*(kstat_t **)p2)->ks_instance); -} - -/* - * Identify those CPUs which were not present for the whole interval so - * their statistics can be removed from the aggregate. - */ -static void -compute_cpu_stat_adj(void) -{ - int i, j; - - if (ocpu_stat_list) { - kstat_t **s[2]; - kstat_t **inarray[2]; - int max_cpus = MAX(ncpus, oncpus); - - qsort(cpu_stat_list, ncpus, sizeof (*cpu_stat_list), - cpuid_compare); - qsort(ocpu_stat_list, oncpus, sizeof (*ocpu_stat_list), - cpuid_compare); - - s[0] = ocpu_stat_list; - s[1] = cpu_stat_list; - - safe_zalloc((void *)&inarray[0], sizeof (**inarray) * max_cpus, - 0); - safe_zalloc((void *)&inarray[1], sizeof (**inarray) * max_cpus, - 0); - diff_two_arrays(s, oncpus, ncpus, inarray); - - for (i = 0; i < max_cpus; i++) { - if (inarray[0][i]) - for (j = 0; j < CPU_STATES; j++) - cpu_stat_adj[j] += - ((cpu_stat_t *)inarray[0][i] - ->ks_data)->cpu_sysinfo.cpu[j]; - if (inarray[1][i]) - for (j = 0; j < CPU_STATES; j++) - cpu_stat_adj[j] -= - ((cpu_stat_t *)inarray[1][i] - ->ks_data)->cpu_sysinfo.cpu[j]; - } - - free(inarray[0]); - free(inarray[1]); - } - - /* - * Preserve the last interval's CPU stats. - */ - if (cpu_stat_list) { - for (i = 0; i < oncpus; i++) - free(ocpu_stat_list[i]->ks_data); - - oncpus = ncpus; - safe_zalloc((void **)&ocpu_stat_list, oncpus * - sizeof (*ocpu_stat_list), 1); - for (i = 0; i < ncpus; i++) { - safe_zalloc((void *)&ocpu_stat_list[i], - sizeof (*ocpu_stat_list[0]), 0); - if (kstat_copy(cpu_stat_list[i], ocpu_stat_list[i])) - fail(1, "kstat_copy() failed"); - } - } -}
--- a/usr/src/cmd/sa/sar.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1282 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -/* - * sar generates a report either from an input data file or by invoking sadc to - * read system activity counters at the specified intervals. - * - * usage: sar [-ubdycwaqvmpgrkA] [-o file] t [n] - * sar [-ubdycwaqvmpgrkA][-s hh:mm][-e hh:mm][-i ss][-f file] - */ - -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/sysinfo.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/utsname.h> -#include <sys/wait.h> - -#include <ctype.h> -#include <errno.h> -#include <fcntl.h> -#include <limits.h> -#include <signal.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <unistd.h> - -#include "sa.h" - -#define PGTOBLK(x) ((x) * (pagesize >> 9)) -#define BLKTOPG(x) ((x) / (pagesize >> 9)) -#define BLKS(x) ((x) >> 9) - -static void prpass(int); -static void prtopt(void); -static void prtavg(void); -static void prttim(void); -static void prtmachid(void); -static void prthdg(void); -static void tsttab(void); -static void update_counters(void); -static void usage(void); -static void fail(int, char *, ...); -static void safe_zalloc(void **, int, int); -static int safe_read(int, void *, size_t); -static void safe_write(int, void *, size_t); -static int safe_strtoi(char const *, char *); -static void ulong_delta(uint64_t *, uint64_t *, uint64_t *, uint64_t *, - int, int); -static float denom(float); -static float freq(float, float); - -static struct sa64 nx, ox, ax, dx; -static iodevinfo_t *nxio, *oxio, *axio, *dxio; -static struct tm *curt, args, arge; - -static int sflg, eflg, iflg, oflg, fflg; -static int realtime, passno = 0, do_disk; -static int t = 0, n = 0, lines = 0; -static int hz; -static int niodevs; -static int tabflg; -static char options[30], fopt[30]; -static float tdiff, sec_diff, totsec_diff = 0.0, percent; -static float start_time, end_time, isec; -static int fin, fout; -static pid_t childid; -static int pipedes[2]; -static char arg1[10], arg2[10]; -static int pagesize; - -/* - * To avoid overflow in the kmem allocation data, declare a copy of the - * main kmeminfo_t type with larger data types. Use this for storing - * the data held to display average values - */ -static struct kmeminfo_l -{ - u_longlong_t km_mem[KMEM_NCLASS]; - u_longlong_t km_alloc[KMEM_NCLASS]; - u_longlong_t km_fail[KMEM_NCLASS]; -} kmi; - -int -main(int argc, char **argv) -{ - char flnm[PATH_MAX], ofile[PATH_MAX]; - char ccc; - time_t temp; - int i, jj = 0; - - pagesize = sysconf(_SC_PAGESIZE); - - /* - * Process options with arguments and pack options - * without arguments. - */ - while ((i = getopt(argc, argv, "ubdycwaqvmpgrkAo:s:e:i:f:")) != EOF) - switch (ccc = (char)i) { - case 'o': - oflg++; - if (strlcpy(ofile, optarg, sizeof (ofile)) >= - sizeof (ofile)) { - fail(2, "-o filename is too long: %s", optarg); - } - break; - case 's': - if (sscanf(optarg, "%d:%d:%d", - &args.tm_hour, &args.tm_min, &args.tm_sec) < 1) - fail(0, "-%c %s -- illegal option argument", - ccc, optarg); - else { - sflg++; - start_time = args.tm_hour*3600.0 + - args.tm_min*60.0 + - args.tm_sec; - } - break; - case 'e': - if (sscanf(optarg, "%d:%d:%d", - &arge.tm_hour, &arge.tm_min, &arge.tm_sec) < 1) - fail(0, "-%c %s -- illegal option argument", - ccc, optarg); - else { - eflg++; - end_time = arge.tm_hour*3600.0 + - arge.tm_min*60.0 + - arge.tm_sec; - } - break; - case 'i': - if (sscanf(optarg, "%f", &isec) < 1) - fail(0, "-%c %s -- illegal option argument", - ccc, optarg); - else { - if (isec > 0.0) - iflg++; - } - break; - case 'f': - fflg++; - if (strlcpy(flnm, optarg, sizeof (flnm)) >= - sizeof (ofile)) { - fail(2, "-f filename is too long: %s", optarg); - } - break; - case '?': - usage(); - exit(1); - break; - default: - - /* - * Check for repeated options. To make sure - * that options[30] does not overflow. - */ - if (strchr(options, ccc) == NULL) - (void) strncat(options, &ccc, 1); - break; - } - - /* - * Are starting and ending times consistent? - */ - if ((sflg) && (eflg) && (end_time <= start_time)) - fail(0, "ending time <= starting time"); - - /* - * Determine if t and n arguments are given, and whether to run in real - * time or from a file. - */ - switch (argc - optind) { - case 0: /* Get input data from file */ - if (fflg == 0) { - temp = time(NULL); - curt = localtime(&temp); - (void) snprintf(flnm, PATH_MAX, "/var/log/sa/sa%.2d", - curt->tm_mday); - } - if ((fin = open(flnm, O_RDONLY)) == -1) - fail(1, "can't open %s", flnm); - break; - case 1: /* Real time data; one cycle */ - realtime++; - t = safe_strtoi(argv[optind], "invalid sampling interval"); - n = 2; - break; - case 2: /* Real time data; specified cycles */ - default: - realtime++; - t = safe_strtoi(argv[optind], "invalid sampling interval"); - n = 1 + safe_strtoi(argv[optind+1], "invalid sample count"); - break; - } - - /* - * "u" is the default option, which displays CPU utilization. - */ - if (strlen(options) == 0) - (void) strcpy(options, "u"); - - /* - * "A" means all data options. - */ - if (strchr(options, 'A') != NULL) - (void) strcpy(options, "udqbwcayvmpgrk"); - - if (realtime) { - /* - * Get input data from sadc via pipe. - */ - if (t <= 0) - fail(0, "sampling interval t <= 0 sec"); - if (n < 2) - fail(0, "number of sample intervals n <= 0"); - (void) sprintf(arg1, "%d", t); - (void) sprintf(arg2, "%d", n); - if (pipe(pipedes) == -1) - fail(1, "pipe failed"); - if ((childid = fork()) == 0) { - /* - * Child: shift pipedes[write] to stdout, - * and close the pipe entries. - */ - (void) dup2(pipedes[1], 1); - if (pipedes[0] != 1) - (void) close(pipedes[0]); - if (pipedes[1] != 1) - (void) close(pipedes[1]); - - if (execlp("/usr/lib/sa/sadc", - "/usr/lib/sa/sadc", arg1, arg2, 0) == -1) - fail(1, "exec of /usr/lib/sa/sadc failed"); - } else if (childid == -1) { - fail(1, "Could not fork to exec sadc"); - } - /* - * Parent: close unused output. - */ - fin = pipedes[0]; - (void) close(pipedes[1]); - } - - if (oflg) { - if (strcmp(ofile, flnm) == 0) - fail(0, "output file name same as input file name"); - fout = creat(ofile, 00644); - } - - hz = sysconf(_SC_CLK_TCK); - - nxio = oxio = dxio = axio = NULL; - - if (realtime) { - /* - * Make single pass, processing all options. - */ - (void) strcpy(fopt, options); - passno++; - prpass(realtime); - (void) kill(childid, SIGINT); - (void) wait(NULL); - } else { - /* - * Make multiple passes, one for each option. - */ - while (strlen(strncpy(fopt, &options[jj++], 1))) { - if (lseek(fin, 0, SEEK_SET) == (off_t)-1) - fail(0, "lseek failed"); - passno++; - prpass(realtime); - } - } - - return (0); -} - -/* - * Convert array of 32-bit uints to 64-bit uints - */ -static void -convert_32to64(uint64_t *dst, uint_t *src, int size) -{ - for (; size > 0; size--) - *dst++ = (uint64_t)(*src++); -} - -/* - * Convert array of 64-bit uints to 32-bit uints - */ -static void -convert_64to32(uint_t *dst, uint64_t *src, int size) -{ - for (; size > 0; size--) - *dst++ = (uint32_t)(*src++); -} - -/* - * Read records from input, classify, and decide on printing. - */ -static void -prpass(int input_pipe) -{ - size_t size; - int i, j, state_change, recno = 0; - kid_t kid; - float trec, tnext = 0; - ulong_t old_niodevs = 0, prev_niodevs = 0; - iodevinfo_t *aio, *dio, *oio; - struct stat in_stat; - struct sa tx; - uint64_t ts, te; /* time interval start and end */ - - do_disk = (strchr(fopt, 'd') != NULL); - if (!input_pipe && fstat(fin, &in_stat) == -1) - fail(1, "unable to stat data file"); - - if (sflg) - tnext = start_time; - - while (safe_read(fin, &tx, sizeof (struct sa))) { - /* - * First, we convert 32-bit tx to 64-bit nx structure - * which is used later. Conversion could be done - * after initial operations, right before calculations, - * but it would introduce additional juggling with vars. - * Thus, we convert all data now, and don't care about - * tx any further. - */ - nx.valid = tx.valid; - nx.ts = tx.ts; - convert_32to64((uint64_t *)&nx.csi, (uint_t *)&tx.csi, - sizeof (tx.csi) / sizeof (uint_t)); - convert_32to64((uint64_t *)&nx.cvmi, (uint_t *)&tx.cvmi, - sizeof (tx.cvmi) / sizeof (uint_t)); - convert_32to64((uint64_t *)&nx.si, (uint_t *)&tx.si, - sizeof (tx.si) / sizeof (uint_t)); - (void) memcpy(&nx.vmi, &tx.vmi, - sizeof (tx) - (((char *)&tx.vmi) - ((char *)&tx))); - /* - * sadc is the only utility used to generate sar data - * and it uses the valid field as follows: - * 0 - dummy record - * 1 - data record - * We can use this fact to improve sar's ability to detect - * bad data, since any value apart from 0 or 1 can be - * interpreted as invalid data. - */ - if (nx.valid != 0 && nx.valid != 1) - fail(2, "data file not in sar format"); - state_change = 0; - niodevs = nx.niodevs; - /* - * niodevs has the value of current number of devices - * from nx structure. - * - * The following 'if' condition is to decide whether memory - * has to be allocated or not if already allocated memory is - * bigger or smaller than memory needed to store the current - * niodevs details in memory. - * - * when first while loop starts, pre_niodevs has 0 and then - * always get initialized to the current number of devices - * from nx.niodevs if it is different from previously read - * niodevs. - * - * if the current niodevs has the same value of previously - * allocated memory i.e, for prev_niodevs, it skips the - * following 'if' loop or otherwise it allocates memory for - * current devises (niodevs) and stores that value in - * prev_niodevs for next time when loop continues to read - * from the file. - */ - if (niodevs != prev_niodevs) { - off_t curr_pos; - /* - * The required buffer size must fit in a size_t. - */ - if (SIZE_MAX / sizeof (iodevinfo_t) < niodevs) - fail(2, "insufficient address space to hold " - "%lu device records", niodevs); - size = niodevs * sizeof (iodevinfo_t); - prev_niodevs = niodevs; - /* - * The data file must exceed this size to be valid. - */ - if (!input_pipe) { - if ((curr_pos = lseek(fin, 0, SEEK_CUR)) == - (off_t)-1) - fail(1, "lseek failed"); - if (in_stat.st_size < curr_pos || - size > in_stat.st_size - curr_pos) - fail(2, "data file corrupt;" - " specified size exceeds actual"); - } - - safe_zalloc((void **)&nxio, size, 1); - } - if (niodevs != old_niodevs) - state_change = 1; - for (i = 0; i < niodevs; i++) { - if (safe_read(fin, &nxio[i], sizeof (iodevinfo_t)) == 0) - fail(1, "premature end-of-file seen"); - if (i < old_niodevs && - nxio[i].ks.ks_kid != oxio[i].ks.ks_kid) - state_change = 1; - } - curt = localtime(&nx.ts); - trec = curt->tm_hour * 3600.0 + - curt->tm_min * 60.0 + - curt->tm_sec; - if ((recno == 0) && (trec < start_time)) - continue; - if ((eflg) && (trec > end_time)) - break; - if ((oflg) && (passno == 1)) { - /* - * The calculated values are stroed in nx strcuture. - * Convert 64-bit nx to 32-bit tx structure. - */ - tx.valid = nx.valid; - tx.ts = nx.ts; - convert_64to32((uint_t *)&tx.csi, (uint64_t *)&nx.csi, - sizeof (nx.csi) / sizeof (uint64_t)); - convert_64to32((uint_t *)&tx.cvmi, (uint64_t *)&nx.cvmi, - sizeof (nx.cvmi) / sizeof (uint64_t)); - convert_64to32((uint_t *)&tx.si, (uint64_t *)&nx.si, - sizeof (nx.si) / sizeof (uint64_t)); - (void) memcpy(&tx.vmi, &nx.vmi, - sizeof (nx) - (((char *)&nx.vmi) - ((char *)&nx))); - if (tx.valid != 0 && tx.valid != 1) - fail(2, "data file not in sar format"); - - safe_write(fout, &tx, sizeof (struct sa)); - for (i = 0; i < niodevs; i++) - safe_write(fout, &nxio[i], - sizeof (iodevinfo_t)); - } - - if (recno == 0) { - if (passno == 1) - prtmachid(); - - prthdg(); - recno = 1; - if ((iflg) && (tnext == 0)) - tnext = trec; - } - - if (nx.valid == 0) { - /* - * This dummy record signifies system restart - * New initial values of counters follow in next - * record. - */ - if (!realtime) { - prttim(); - (void) printf("\tunix restarts\n"); - recno = 1; - continue; - } - } - if ((iflg) && (trec < tnext)) - continue; - - if (state_change) { - /* - * Either the number of devices or the ordering of - * the kstats has changed. We need to re-organise - * the layout of our avg/delta arrays so that we - * can cope with this in update_counters(). - */ - size = niodevs * sizeof (iodevinfo_t); - safe_zalloc((void *)&aio, size, 0); - safe_zalloc((void *)&dio, size, 0); - safe_zalloc((void *)&oio, size, 0); - - /* - * Loop through all the newly read iodev's, locate - * the corresponding entry in the old arrays and - * copy the entries into the same bucket of the - * new arrays. - */ - for (i = 0; i < niodevs; i++) { - kid = nxio[i].ks.ks_kid; - for (j = 0; j < old_niodevs; j++) { - if (oxio[j].ks.ks_kid == kid) { - oio[i] = oxio[j]; - aio[i] = axio[j]; - dio[i] = dxio[j]; - } - } - } - - free(axio); - free(oxio); - free(dxio); - - axio = aio; - oxio = oio; - dxio = dio; - - old_niodevs = niodevs; - } - - if (recno++ > 1) { - ts = ox.csi.cpu[0] + ox.csi.cpu[1] + - ox.csi.cpu[2] + ox.csi.cpu[3]; - te = nx.csi.cpu[0] + nx.csi.cpu[1] + - nx.csi.cpu[2] + nx.csi.cpu[3]; - tdiff = (float)(te - ts); - sec_diff = tdiff / hz; - percent = 100.0 / tdiff; - - /* - * If the CPU stat counters have rolled - * backward, this is our best indication that - * a CPU has been offlined. We don't have - * enough data to compute a sensible delta, so - * toss out this interval, but compute the next - * interval's delta from these values. - */ - if (tdiff <= 0) { - ox = nx; - continue; - } - update_counters(); - prtopt(); - lines++; - if (passno == 1) - totsec_diff += sec_diff; - } - ox = nx; /* Age the data */ - (void) memcpy(oxio, nxio, niodevs * sizeof (iodevinfo_t)); - if (isec > 0) - while (tnext <= trec) - tnext += isec; - } - /* - * After this place, all functions are using niodevs to access the - * memory for device details. Here, old_niodevs has the correct value - * of memory allocated for storing device information. Since niodevs - * doesn't have correct value, sometimes, it was corrupting memory. - */ - niodevs = old_niodevs; - if (lines > 1) - prtavg(); - (void) memset(&ax, 0, sizeof (ax)); /* Zero out the accumulators. */ - (void) memset(&kmi, 0, sizeof (kmi)); - lines = 0; - /* - * axio will not be allocated if the user specified -e or -s, and - * no records in the file fell inside the specified time range. - */ - if (axio) { - (void) memset(axio, 0, niodevs * sizeof (iodevinfo_t)); - } -} - -/* - * Print time label routine. - */ -static void -prttim(void) -{ - curt = localtime(&nx.ts); - (void) printf("%.2d:%.2d:%.2d", curt->tm_hour, curt->tm_min, - curt->tm_sec); - tabflg = 1; -} - -/* - * Test if 8-spaces to be added routine. - */ -static void -tsttab(void) -{ - if (tabflg == 0) - (void) printf(" "); - else - tabflg = 0; -} - -/* - * Print machine identification. - */ -static void -prtmachid(void) -{ - struct utsname name; - - (void) uname(&name); - (void) printf("\n%s %s %s %s %s %.2d/%.2d/%.4d\n", - name.sysname, name.nodename, name.release, name.version, - name.machine, curt->tm_mon + 1, curt->tm_mday, - curt->tm_year + 1900); -} - -/* - * Print report heading routine. - */ -static void -prthdg(void) -{ - int jj = 0; - char ccc; - - (void) printf("\n"); - prttim(); - while ((ccc = fopt[jj++]) != '\0') { - tsttab(); - switch (ccc) { - case 'u': - (void) printf(" %7s %7s %7s %7s\n", - "%usr", - "%sys", - "%wio", - "%idle"); - break; - case 'b': - (void) printf(" %7s %7s %7s %7s %7s %7s %7s %7s\n", - "bread/s", - "lread/s", - "%rcache", - "bwrit/s", - "lwrit/s", - "%wcache", - "pread/s", - "pwrit/s"); - break; - case 'd': - (void) printf(" %-8.8s %7s %7s %7s %7s %7s %7s\n", - "device", - "%busy", - "avque", - "r+w/s", - "blks/s", - "avwait", - "avserv"); - break; - case 'y': - (void) printf(" %7s %7s %7s %7s %7s %7s\n", - "rawch/s", - "canch/s", - "outch/s", - "rcvin/s", - "xmtin/s", - "mdmin/s"); - break; - case 'c': - (void) printf(" %7s %7s %7s %7s %7s %7s %7s\n", - "scall/s", - "sread/s", - "swrit/s", - "fork/s", - "exec/s", - "rchar/s", - "wchar/s"); - break; - case 'w': - (void) printf(" %7s %7s %7s %7s %7s\n", - "swpin/s", - "bswin/s", - "swpot/s", - "bswot/s", - "pswch/s"); - break; - case 'a': - (void) printf(" %7s %7s %7s\n", - "iget/s", - "namei/s", - "dirbk/s"); - break; - case 'q': - (void) printf(" %7s %7s %7s %7s\n", - "runq-sz", - "%runocc", - "swpq-sz", - "%swpocc"); - break; - case 'v': - (void) printf(" %s %s %s %s\n", - "proc-sz ov", - "inod-sz ov", - "file-sz ov", - "lock-sz"); - break; - case 'm': - (void) printf(" %7s %7s\n", - "msg/s", - "sema/s"); - break; - case 'p': - (void) printf(" %7s %7s %7s %7s %7s %7s\n", - "atch/s", - "pgin/s", - "ppgin/s", - "pflt/s", - "vflt/s", - "slock/s"); - break; - case 'g': - (void) printf(" %8s %8s %8s %8s %8s\n", - "pgout/s", - "ppgout/s", - "pgfree/s", - "pgscan/s", - "%ufs_ipf"); - break; - case 'r': - (void) printf(" %7s %8s\n", - "freemem", - "freeswap"); - break; - case 'k': - (void) printf(" %7s %7s %5s %7s %7s %5s %11s %5s\n", - "sml_mem", - "alloc", - "fail", - "lg_mem", - "alloc", - "fail", - "ovsz_alloc", - "fail"); - break; - } - } - if (jj > 2 || do_disk) - (void) printf("\n"); -} - -/* - * compute deltas and update accumulators - */ -static void -update_counters(void) -{ - int i; - iodevinfo_t *nio, *oio, *aio, *dio; - - ulong_delta((uint64_t *)&nx.csi, (uint64_t *)&ox.csi, - (uint64_t *)&dx.csi, (uint64_t *)&ax.csi, 0, sizeof (ax.csi)); - ulong_delta((uint64_t *)&nx.si, (uint64_t *)&ox.si, - (uint64_t *)&dx.si, (uint64_t *)&ax.si, 0, sizeof (ax.si)); - ulong_delta((uint64_t *)&nx.cvmi, (uint64_t *)&ox.cvmi, - (uint64_t *)&dx.cvmi, (uint64_t *)&ax.cvmi, 0, - sizeof (ax.cvmi)); - - ax.vmi.freemem += dx.vmi.freemem = nx.vmi.freemem - ox.vmi.freemem; - ax.vmi.swap_avail += dx.vmi.swap_avail = - nx.vmi.swap_avail - ox.vmi.swap_avail; - - nio = nxio; - oio = oxio; - aio = axio; - dio = dxio; - for (i = 0; i < niodevs; i++) { - aio->kios.wlastupdate += dio->kios.wlastupdate - = nio->kios.wlastupdate - oio->kios.wlastupdate; - aio->kios.reads += dio->kios.reads - = nio->kios.reads - oio->kios.reads; - aio->kios.writes += dio->kios.writes - = nio->kios.writes - oio->kios.writes; - aio->kios.nread += dio->kios.nread - = nio->kios.nread - oio->kios.nread; - aio->kios.nwritten += dio->kios.nwritten - = nio->kios.nwritten - oio->kios.nwritten; - aio->kios.wlentime += dio->kios.wlentime - = nio->kios.wlentime - oio->kios.wlentime; - aio->kios.rlentime += dio->kios.rlentime - = nio->kios.rlentime - oio->kios.rlentime; - aio->kios.wtime += dio->kios.wtime - = nio->kios.wtime - oio->kios.wtime; - aio->kios.rtime += dio->kios.rtime - = nio->kios.rtime - oio->kios.rtime; - aio->ks.ks_snaptime += dio->ks.ks_snaptime - = nio->ks.ks_snaptime - oio->ks.ks_snaptime; - nio++; - oio++; - aio++; - dio++; - } -} - -static void -prt_u_opt(struct sa64 *xx) -{ - (void) printf(" %7.0f %7.0f %7.0f %7.0f\n", - (float)xx->csi.cpu[1] * percent, - (float)xx->csi.cpu[2] * percent, - (float)xx->csi.cpu[3] * percent, - (float)xx->csi.cpu[0] * percent); -} - -static void -prt_b_opt(struct sa64 *xx) -{ - (void) printf(" %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f\n", - (float)xx->csi.bread / sec_diff, - (float)xx->csi.lread / sec_diff, - freq((float)xx->csi.lread, (float)xx->csi.bread), - (float)xx->csi.bwrite / sec_diff, - (float)xx->csi.lwrite / sec_diff, - freq((float)xx->csi.lwrite, (float)xx->csi.bwrite), - (float)xx->csi.phread / sec_diff, - (float)xx->csi.phwrite / sec_diff); -} - -static void -prt_d_opt(int ii, iodevinfo_t *xio) -{ - double etime, hr_etime, tps, avq, avs, pbusy; - - tsttab(); - - hr_etime = (double)xio[ii].ks.ks_snaptime; - if (hr_etime == 0.0) - hr_etime = (double)NANOSEC; - pbusy = (double)xio[ii].kios.rtime * 100.0 / hr_etime; - if (pbusy > 100.0) - pbusy = 100.0; - etime = hr_etime / (double)NANOSEC; - tps = (double)(xio[ii].kios.reads + xio[ii].kios.writes) / etime; - avq = (double)xio[ii].kios.wlentime / hr_etime; - avs = (double)xio[ii].kios.rlentime / hr_etime; - - (void) printf(" %-8.8s ", nxio[ii].ks.ks_name); - (void) printf("%7.0f %7.1f %7.0f %7.0f %7.1f %7.1f\n", - pbusy, - avq + avs, - tps, - BLKS(xio[ii].kios.nread + xio[ii].kios.nwritten) / etime, - (tps > 0 ? avq / tps * 1000.0 : 0.0), - (tps > 0 ? avs / tps * 1000.0 : 0.0)); -} - -static void -prt_y_opt(struct sa64 *xx) -{ - (void) printf(" %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f\n", - (float)xx->csi.rawch / sec_diff, - (float)xx->csi.canch / sec_diff, - (float)xx->csi.outch / sec_diff, - (float)xx->csi.rcvint / sec_diff, - (float)xx->csi.xmtint / sec_diff, - (float)xx->csi.mdmint / sec_diff); -} - -static void -prt_c_opt(struct sa64 *xx) -{ - (void) printf(" %7.0f %7.0f %7.0f %7.2f %7.2f %7.0f %7.0f\n", - (float)xx->csi.syscall / sec_diff, - (float)xx->csi.sysread / sec_diff, - (float)xx->csi.syswrite / sec_diff, - (float)(xx->csi.sysfork + xx->csi.sysvfork) / sec_diff, - (float)xx->csi.sysexec / sec_diff, - (float)xx->csi.readch / sec_diff, - (float)xx->csi.writech / sec_diff); -} - -static void -prt_w_opt(struct sa64 *xx) -{ - (void) printf(" %7.2f %7.1f %7.2f %7.1f %7.0f\n", - (float)xx->cvmi.swapin / sec_diff, - (float)PGTOBLK(xx->cvmi.pgswapin) / sec_diff, - (float)xx->cvmi.swapout / sec_diff, - (float)PGTOBLK(xx->cvmi.pgswapout) / sec_diff, - (float)xx->csi.pswitch / sec_diff); -} - -static void -prt_a_opt(struct sa64 *xx) -{ - (void) printf(" %7.0f %7.0f %7.0f\n", - (float)xx->csi.ufsiget / sec_diff, - (float)xx->csi.namei / sec_diff, - (float)xx->csi.ufsdirblk / sec_diff); -} - -static void -prt_q_opt(struct sa64 *xx) -{ - if (xx->si.runocc == 0 || xx->si.updates == 0) - (void) printf(" %7.1f %7.0f", 0., 0.); - else { - (void) printf(" %7.1f %7.0f", - (float)xx->si.runque / (float)xx->si.runocc, - (float)xx->si.runocc / (float)xx->si.updates * 100.0); - } - if (xx->si.swpocc == 0 || xx->si.updates == 0) - (void) printf(" %7.1f %7.0f\n", 0., 0.); - else { - (void) printf(" %7.1f %7.0f\n", - (float)xx->si.swpque / (float)xx->si.swpocc, - (float)xx->si.swpocc / (float)xx->si.updates * 100.0); - } -} - -static void -prt_v_opt(struct sa64 *xx) -{ - (void) printf(" %4lu/%-4lu %4llu %4lu/%-4lu %4llu %4lu/%-4lu " - "%4llu %4lu/%-4lu\n", - nx.szproc, nx.mszproc, xx->csi.procovf, - nx.szinode, nx.mszinode, xx->csi.inodeovf, - nx.szfile, nx.mszfile, xx->csi.fileovf, - nx.szlckr, nx.mszlckr); -} - -static void -prt_m_opt(struct sa64 *xx) -{ - (void) printf(" %7.2f %7.2f\n", - (float)xx->csi.msg / sec_diff, - (float)xx->csi.sema / sec_diff); -} - -static void -prt_p_opt(struct sa64 *xx) -{ - (void) printf(" %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n", - (float)xx->cvmi.pgfrec / sec_diff, - (float)xx->cvmi.pgin / sec_diff, - (float)xx->cvmi.pgpgin / sec_diff, - (float)(xx->cvmi.prot_fault + xx->cvmi.cow_fault) / sec_diff, - (float)(xx->cvmi.hat_fault + xx->cvmi.as_fault) / sec_diff, - (float)xx->cvmi.softlock / sec_diff); -} - -static void -prt_g_opt(struct sa64 *xx) -{ - (void) printf(" %8.2f %8.2f %8.2f %8.2f %8.2f\n", - (float)xx->cvmi.pgout / sec_diff, - (float)xx->cvmi.pgpgout / sec_diff, - (float)xx->cvmi.dfree / sec_diff, - (float)xx->cvmi.scan / sec_diff, - (float)xx->csi.ufsipage * 100.0 / - denom((float)xx->csi.ufsipage + - (float)xx->csi.ufsinopage)); -} - -static void -prt_r_opt(struct sa64 *xx) -{ - /* Avoid divide by Zero - Should never happen */ - if (xx->si.updates == 0) - (void) printf(" %7.0f %8.0f\n", 0., 0.); - else { - (void) printf(" %7.0f %8.0f\n", - (double)xx->vmi.freemem / (float)xx->si.updates, - (double)PGTOBLK(xx->vmi.swap_avail) / - (float)xx->si.updates); - } -} - -static void -prt_k_opt(struct sa64 *xx, int n) -{ - if (n != 1) { - (void) printf(" %7.0f %7.0f %5.0f %7.0f %7.0f %5.0f %11.0f" - " %5.0f\n", - (float)kmi.km_mem[KMEM_SMALL] / n, - (float)kmi.km_alloc[KMEM_SMALL] / n, - (float)kmi.km_fail[KMEM_SMALL] / n, - (float)kmi.km_mem[KMEM_LARGE] / n, - (float)kmi.km_alloc[KMEM_LARGE] / n, - (float)kmi.km_fail[KMEM_LARGE] / n, - (float)kmi.km_alloc[KMEM_OSIZE] / n, - (float)kmi.km_fail[KMEM_OSIZE] / n); - } else { - /* - * If we are not reporting averages, use the read values - * directly. - */ - (void) printf(" %7.0f %7.0f %5.0f %7.0f %7.0f %5.0f %11.0f" - " %5.0f\n", - (float)xx->kmi.km_mem[KMEM_SMALL], - (float)xx->kmi.km_alloc[KMEM_SMALL], - (float)xx->kmi.km_fail[KMEM_SMALL], - (float)xx->kmi.km_mem[KMEM_LARGE], - (float)xx->kmi.km_alloc[KMEM_LARGE], - (float)xx->kmi.km_fail[KMEM_LARGE], - (float)xx->kmi.km_alloc[KMEM_OSIZE], - (float)xx->kmi.km_fail[KMEM_OSIZE]); - } -} - -/* - * Print options routine. - */ -static void -prtopt(void) -{ - int ii, jj = 0; - char ccc; - - prttim(); - - while ((ccc = fopt[jj++]) != '\0') { - if (ccc != 'd') - tsttab(); - switch (ccc) { - case 'u': - prt_u_opt(&dx); - break; - case 'b': - prt_b_opt(&dx); - break; - case 'd': - for (ii = 0; ii < niodevs; ii++) - prt_d_opt(ii, dxio); - break; - case 'y': - prt_y_opt(&dx); - break; - case 'c': - prt_c_opt(&dx); - break; - case 'w': - prt_w_opt(&dx); - break; - case 'a': - prt_a_opt(&dx); - break; - case 'q': - prt_q_opt(&dx); - break; - case 'v': - prt_v_opt(&dx); - break; - case 'm': - prt_m_opt(&dx); - break; - case 'p': - prt_p_opt(&dx); - break; - case 'g': - prt_g_opt(&dx); - break; - case 'r': - prt_r_opt(&dx); - break; - case 'k': - prt_k_opt(&nx, 1); - /* - * To avoid overflow, copy the data from the sa record - * into a struct kmeminfo_l which has members with - * larger data types. - */ - kmi.km_mem[KMEM_SMALL] += nx.kmi.km_mem[KMEM_SMALL]; - kmi.km_alloc[KMEM_SMALL] += nx.kmi.km_alloc[KMEM_SMALL]; - kmi.km_fail[KMEM_SMALL] += nx.kmi.km_fail[KMEM_SMALL]; - kmi.km_mem[KMEM_LARGE] += nx.kmi.km_mem[KMEM_LARGE]; - kmi.km_alloc[KMEM_LARGE] += nx.kmi.km_alloc[KMEM_LARGE]; - kmi.km_fail[KMEM_LARGE] += nx.kmi.km_fail[KMEM_LARGE]; - kmi.km_alloc[KMEM_OSIZE] += nx.kmi.km_alloc[KMEM_OSIZE]; - kmi.km_fail[KMEM_OSIZE] += nx.kmi.km_fail[KMEM_OSIZE]; - break; - } - } - if (jj > 2 || do_disk) - (void) printf("\n"); - if (realtime) - (void) fflush(stdout); -} - -/* - * Print average routine. - */ -static void -prtavg(void) -{ - int ii, jj = 0; - char ccc; - - tdiff = ax.csi.cpu[0] + ax.csi.cpu[1] + ax.csi.cpu[2] + ax.csi.cpu[3]; - if (tdiff <= 0.0) - return; - - sec_diff = tdiff / hz; - percent = 100.0 / tdiff; - (void) printf("\n"); - - while ((ccc = fopt[jj++]) != '\0') { - if (ccc != 'v') - (void) printf("Average "); - switch (ccc) { - case 'u': - prt_u_opt(&ax); - break; - case 'b': - prt_b_opt(&ax); - break; - case 'd': - tabflg = 1; - for (ii = 0; ii < niodevs; ii++) - prt_d_opt(ii, axio); - break; - case 'y': - prt_y_opt(&ax); - break; - case 'c': - prt_c_opt(&ax); - break; - case 'w': - prt_w_opt(&ax); - break; - case 'a': - prt_a_opt(&ax); - break; - case 'q': - prt_q_opt(&ax); - break; - case 'v': - break; - case 'm': - prt_m_opt(&ax); - break; - case 'p': - prt_p_opt(&ax); - break; - case 'g': - prt_g_opt(&ax); - break; - case 'r': - prt_r_opt(&ax); - break; - case 'k': - prt_k_opt(&ax, lines); - break; - } - } -} - -static void -ulong_delta(uint64_t *new, uint64_t *old, uint64_t *delta, uint64_t *accum, - int begin, int end) -{ - int i; - uint64_t n, o, d; - - for (i = begin; i < end; i += sizeof (uint64_t)) { - n = *new++; - o = *old++; - if (o > n) { - d = n + 0x100000000LL - o; - } else { - d = n - o; - } - *accum++ += *delta++ = d; - } -} - -/* - * used to prevent zero denominators - */ -static float -denom(float x) -{ - return ((x > 0.5) ? x : 1.0); -} - -/* - * a little calculation that comes up often when computing frequency - * of one operation relative to another - */ -static float -freq(float x, float y) -{ - return ((x < 0.5) ? 100.0 : (x - y) / x * 100.0); -} - -static void -usage(void) -{ - (void) fprintf(stderr, - "usage: sar [-ubdycwaqvmpgrkA][-o file] t [n]\n" - "\tsar [-ubdycwaqvmpgrkA] [-s hh:mm][-e hh:mm][-i ss][-f file]\n"); -} - -static void -fail(int do_perror, char *message, ...) -{ - va_list args; - - va_start(args, message); - (void) fprintf(stderr, "sar: "); - (void) vfprintf(stderr, message, args); - va_end(args); - (void) fprintf(stderr, "\n"); - switch (do_perror) { - case 0: /* usage message */ - usage(); - break; - case 1: /* perror output */ - perror(""); - break; - case 2: /* no further output */ - break; - default: /* error */ - (void) fprintf(stderr, "unsupported failure mode\n"); - break; - } - exit(2); -} - -static int -safe_strtoi(char const *val, char *errmsg) -{ - char *end; - long tmp; - - errno = 0; - tmp = strtol(val, &end, 10); - if (*end != '\0' || errno) - fail(0, "%s %s", errmsg, val); - return ((int)tmp); -} - -static void -safe_zalloc(void **ptr, int size, int free_first) -{ - if (free_first) - free(*ptr); - if ((*ptr = malloc(size)) == NULL) - fail(1, "malloc failed"); - (void) memset(*ptr, 0, size); -} - -static int -safe_read(int fd, void *buf, size_t size) -{ - size_t rsize = read(fd, buf, size); - - if (rsize == 0) - return (0); - - if (rsize != size) - fail(1, "read failed"); - - return (1); -} - -static void -safe_write(int fd, void *buf, size_t size) -{ - if (write(fd, buf, size) != size) - fail(1, "write failed"); -}
--- a/usr/src/cmd/sa/sar.xml Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> -<!-- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - ident "%Z%%M% %I% %E% SMI" - - NOTE: This service manifest is not editable; its contents will - be overwritten by package or patch operations, including - operating system upgrade. Make customizations in a different - file. ---> - -<service_bundle type='manifest' name='SUNWaccr:sar'> - -<service - name='system/sar' - type='service' - version='1'> - - <create_default_instance enabled='false' /> - - <single_instance /> - - <dependency - name='usr' - type='service' - grouping='require_all' - restart_on='none'> - <service_fmri value='svc:/system/filesystem/minimal' /> - </dependency> - - <exec_method - type='method' - name='start' - exec='/lib/svc/method/svc-sar %m' - timeout_seconds='60'> - <method_context> - <method_credential - user='sys' - group='sys' - privileges='basic,file_dac_write' /> - </method_context> - </exec_method> - - <exec_method - type='method' - name='stop' - exec='/lib/svc/method/svc-sar %m' - timeout_seconds='60'> - <method_context> - <method_credential - user='sys' - group='sys' - privileges='basic,file_dac_write' /> - </method_context> - </exec_method> - - <property_group name='startd' type='framework'> - <propval name='duration' type='astring' value='transient' /> - </property_group> - - <stability value='Unstable' /> - - <template> - <common_name> - <loctext xml:lang='C'> - system activity reporting package - </loctext> - </common_name> - <documentation> - <manpage title='sar' section='8' manpath='/usr/share/man' /> - </documentation> - </template> -</service> - -</service_bundle>
--- a/usr/src/cmd/sa/svc-sar Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T -# All Rights Reserved -# -#ident "%Z%%M% %I% %E% SMI" -# -# Start method script for the system activity reporting service. -# -# To enable periodic collection of data, you may need to uncomment -# the entries in /var/spool/cron/crontabs/sys - -arg=$1 - -set -- `/usr/bin/who -r` -_INIT_RUN_NPREV="$8" -# utmpx's runlevel entries are only set on reaching single-user, -# so there might not be a who -r entry yet. -[ -z "$_INIT_RUN_NPREV" ] && _INIT_RUN_NPREV=0 - -case "$arg" in -'start') - if [ $_INIT_RUN_NPREV -eq 0 ]; then - - /usr/lib/sa/sadc /var/log/sa/sa`date +%d` - - if [ ! -f /var/spool/cron/crontabs/sys ]; then - cat << EOF > /var/spool/cron/crontabs/sys -# -# sys crontab -# -# The sys crontab should be used to do performance collection. -# Please note that if the system/sar service is disabled this file -# will be deleted. Please keep a backup copy if you change the -# defaults. -# -0 * * * 0-6 /usr/lib/sa/sa1 -20,40 8-17 * * 1-5 /usr/lib/sa/sa1 -5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A -EOF - fi - fi - ;; -'stop') - rm /var/spool/cron/crontabs/sys - ;; -*) - echo "Usage: $0 { start | stop }" - exit 1 - ;; -esac - -exit 0
--- a/usr/src/cmd/sa/timex.c Mon May 20 17:16:39 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,281 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <sys/times.h> -#include <sys/time.h> -#include <sys/param.h> -#include <sys/wait.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <strings.h> -#include <time.h> -#include <errno.h> -#include <pwd.h> - -#define NSEC_TO_TICK(nsec) ((nsec) / nsec_per_tick) -#define NSEC_TO_TICK_ROUNDUP(nsec) NSEC_TO_TICK((nsec) + \ - nsec_per_tick/2) - -char fname[20]; -static int hz; -static int nsec_per_tick; - -void printt(char *, hrtime_t); -void hmstime(char[]); -void usage(); - -int -main(int argc, char **argv) -{ - struct tms buffer, obuffer; - int status; - register pid_t p; - int c; - hrtime_t before, after, timediff; - char stime[9], etime[9]; - char cmd[80]; - int pflg = 0, sflg = 0, oflg = 0; - char aopt[25]; - FILE *pipin; - char ttyid[12], line[150]; - char eol; - char fld[20][12]; - int iline = 0, i, nfld; - int ichar, iblok; - long chars = 0, bloks = 0; - - aopt[0] = '\0'; - - hz = sysconf(_SC_CLK_TCK); - nsec_per_tick = NANOSEC / hz; - - /* check options; */ - while ((c = getopt(argc, argv, "sopfhkmrt")) != EOF) - switch (c) { - case 's': sflg++; break; - case 'o': oflg++; break; - case 'p': pflg++; break; - - case 'f': strcat(aopt, "-f "); break; - case 'h': strcat(aopt, "-h "); break; - case 'k': strcat(aopt, "-k "); break; - case 'm': strcat(aopt, "-m "); break; - case 'r': strcat(aopt, "-r "); break; - case 't': strcat(aopt, "-t "); break; - - case '?': usage(); - break; - } - if (optind >= argc) { - fprintf(stderr, "timex: Missing command\n"); - usage(); - } - - /* - * Check to see if accounting is installed and print a somewhat - * meaninful message if not. - */ - if (((oflg+pflg) != 0) && (access("/usr/bin/acctcom", 01) == -1)) { - oflg = 0; - pflg = 0; - fprintf(stderr, - "Information from -p and -o options not available\n"); - fprintf(stderr, - " because process accounting is not operational.\n"); - } - - if (sflg) { - sprintf(fname, "/tmp/tmx%ld", getpid()); - sprintf(cmd, "/usr/lib/sa/sadc 1 1 %s", fname); - system(cmd); - } - if (pflg + oflg) hmstime(stime); - before = gethrtime(); - (void) times(&obuffer); - if ((p = fork()) == (pid_t)-1) { - perror("Fork Failed"); - (void) unlink(fname); - exit(EXIT_FAILURE); - } - if (p == 0) { - setgid(getgid()); - execvp(*(argv+optind), (argv+optind)); - fprintf(stderr, "%s: %s\n", *(argv+optind), strerror(errno)); - exit(EXIT_FAILURE); - } - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - while (wait(&status) != p) - ; - if ((status&0377) != 0) - fprintf(stderr, "Command terminated abnormally.\n"); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - (void) times(&buffer); - after = gethrtime(); - timediff = after - before; - if (pflg + oflg) hmstime(etime); - if (sflg) system(cmd); - - fprintf(stderr, "\n"); - printt("real", NSEC_TO_TICK_ROUNDUP(timediff)); - printt("user", buffer.tms_cutime - obuffer.tms_cutime); - printt("sys ", buffer.tms_cstime - obuffer.tms_cstime); - fprintf(stderr, "\n"); - - if (oflg+pflg) { - if (isatty(0)) - sprintf(ttyid, "-l %s", ttyname(0)+5); - sprintf(cmd, "acctcom -S %s -E %s -u %s %s -i %s", - stime, etime, getpwuid(getuid())->pw_name, ttyid, aopt); - pipin = popen(cmd, "r"); - while (fscanf(pipin, "%[^\n]%1c", line, &eol) > 1) { - if (pflg) - fprintf(stderr, "%s\n", line); - if (oflg) { - nfld = sscanf(line, - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", - fld[0], fld[1], fld[2], fld[3], fld[4], - fld[5], fld[6], fld[7], fld[8], fld[9], - fld[10], fld[11], fld[12], fld[13], fld[14], - fld[15], fld[16], fld[17], fld[18], - fld[19]); - if (++iline == 3) - for (i = 0; i < nfld; i++) { - if (strcmp(fld[i], "CHARS") - == 0) - ichar = i+2; - if (strcmp(fld[i], "BLOCKS") - == 0) - iblok = i+2; - } - if (iline > 4) { - chars += atol(fld[ichar]); - bloks += atol(fld[iblok]); - } - } - } - pclose(pipin); - - if (oflg) - if (iline > 4) - fprintf(stderr, - "\nCHARS TRNSFD = %ld\n" - "BLOCKS READ = %ld\n", chars, bloks); - else - fprintf(stderr, - "\nNo process records found!\n"); - } - - if (sflg) { - sprintf(cmd, "/usr/bin/sar -ubdycwaqvmpgrk -f %s 1>&2", fname); - system(cmd); - unlink(fname); - } - exit(WEXITSTATUS(status)); -} - -void -printt(char *label, hrtime_t ticks) -{ - long tk; /* number of leftover ticks */ - long ss; /* number of seconds */ - long mm; /* number of minutes */ - long hh; /* number of hours */ - longlong_t total = ticks; - - tk = total % hz; /* ticks % hz */ - total /= hz; - ss = total % 60; /* ticks / hz % 60 */ - total /= 60; - mm = total % 60; /* ticks / hz / 60 % 60 */ - hh = total / 60; /* ticks / hz / 60 / 60 */ - - (void) fprintf(stderr, "%s ", label); - - /* Display either padding or the elapsed hours */ - if (hh == 0L) { - (void) fprintf(stderr, "%6c", ' '); - } else { - (void) fprintf(stderr, "%5ld:", hh); - } - - /* - * Display either nothing or the elapsed minutes, zero - * padding (if hours > 0) or space padding (if not). - */ - if (mm == 0L && hh == 0L) { - (void) fprintf(stderr, "%3c", ' '); - } else if (mm != 0L && hh == 0L) { - (void) fprintf(stderr, "%2ld:", mm); - } else { - (void) fprintf(stderr, "%02ld:", mm); - } - - /* - * Display the elapsed seconds; seconds are always - * zero padded. - */ - if (hh == 0L && mm == 0L) { - (void) fprintf(stderr, "%2ld.", ss); - } else { - (void) fprintf(stderr, "%02ld.", ss); - } - - /* Display hundredths of a second. */ - (void) fprintf(stderr, "%02ld\n", tk * 100/hz); -} - -/* - * hmstime() sets current time in hh:mm:ss string format in stime; - */ - -void -hmstime(char stime[]) -{ - char *ltime; - time_t tme; - - tme = time((time_t *)0); - ltime = ctime(&tme); - strncpy(stime, ltime+11, 8); - stime[8] = '\0'; -} - -void -usage() -{ - fprintf(stderr, "Usage: timex [-o] [-p [-fhkmrt]] [-s] command\n"); - unlink(fname); - exit(EXIT_FAILURE); -}
--- a/usr/src/pkg/manifests/system-accounting-legacy.mf Mon May 20 17:16:39 2019 -0400 +++ b/usr/src/pkg/manifests/system-accounting-legacy.mf Mon May 20 19:46:49 2019 -0400 @@ -1,122 +1,2 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2012 Nexenta Systems, Inc. All rights reserved. -# - set name=pkg.fmri value=pkg:/system/accounting/legacy@$(PKGVERS) -set name=pkg.description \ - value="utilities for accounting and reporting of system activity" -set name=pkg.summary value="System Accounting" -set name=info.classification \ - value="org.opensolaris.category.2008:System/Administration and Configuration" -set name=variant.arch value=$(ARCH) -dir path=etc group=sys -dir path=etc/acct group=adm owner=adm -dir path=etc/init.d group=sys -dir path=lib -dir path=lib/svc -dir path=lib/svc/manifest group=sys -dir path=lib/svc/manifest/system group=sys -dir path=lib/svc/method -dir path=usr group=sys -dir path=usr/bin -dir path=usr/lib -dir path=usr/lib/acct -dir path=usr/lib/sa owner=adm -dir path=usr/sbin -dir path=usr/share -dir path=usr/share/man -dir path=usr/share/man/man1 -dir path=usr/share/man/man4 -dir path=usr/share/man/man8 -dir path=var group=sys -dir path=var/log group=sys -dir path=var/log/acct group=adm mode=0775 owner=adm -dir path=var/log/acct/fiscal group=adm mode=0775 owner=adm -dir path=var/log/acct/nite group=adm mode=0775 owner=adm -dir path=var/log/acct/sum group=adm mode=0775 owner=adm -dir path=var/log/sa group=sys mode=0775 owner=adm -dir path=var/spool -dir path=var/spool/cron group=sys -dir path=var/spool/cron/crontabs group=sys -file path=etc/acct/holidays preserve=true -file path=etc/init.d/acct group=sys mode=0744 preserve=true -file path=lib/svc/manifest/system/sar.xml group=sys mode=0444 -file path=lib/svc/method/svc-sar group=sys mode=0555 -file path=usr/bin/acctcom mode=0555 -file path=usr/bin/timex group=sys mode=0555 -file path=usr/lib/acct/acctcms mode=0555 -file path=usr/lib/acct/acctcon mode=0555 -file path=usr/lib/acct/acctcon1 mode=0555 -file path=usr/lib/acct/acctcon2 mode=0555 -file path=usr/lib/acct/acctdisk mode=0555 -file path=usr/lib/acct/acctdusg mode=0555 -file path=usr/lib/acct/acctmerg mode=0555 -file path=usr/lib/acct/accton group=adm mode=4755 -file path=usr/lib/acct/acctprc mode=0555 -file path=usr/lib/acct/acctprc1 mode=0555 -file path=usr/lib/acct/acctprc2 mode=0555 -file path=usr/lib/acct/acctwtmp mode=0555 -file path=usr/lib/acct/chargefee mode=0555 -file path=usr/lib/acct/ckpacct mode=0555 -file path=usr/lib/acct/closewtmp mode=0555 -file path=usr/lib/acct/dodisk mode=0555 -file path=usr/lib/acct/fwtmp mode=0555 -file path=usr/lib/acct/lastlogin mode=0555 -file path=usr/lib/acct/monacct mode=0555 -file path=usr/lib/acct/nulladm mode=0555 -file path=usr/lib/acct/prctmp mode=0555 -file path=usr/lib/acct/prdaily mode=0555 -file path=usr/lib/acct/prtacct mode=0555 -file path=usr/lib/acct/ptecms.awk mode=0555 -file path=usr/lib/acct/ptelus.awk mode=0555 -file path=usr/lib/acct/remove mode=0555 -file path=usr/lib/acct/runacct mode=0555 -file path=usr/lib/acct/shutacct mode=0555 -file path=usr/lib/acct/startup mode=0555 -file path=usr/lib/acct/turnacct mode=0555 -file path=usr/lib/acct/utmp2wtmp mode=0555 -file path=usr/lib/acct/wtmpfix mode=0555 -file path=usr/lib/sa/sa1 mode=0555 -file path=usr/lib/sa/sa2 mode=0555 -file path=usr/lib/sa/sadc mode=0555 -file path=usr/sbin/sar mode=0555 -file path=usr/share/man/man1/acctcom.1 -file path=usr/share/man/man1/sar.1 -file path=usr/share/man/man1/timex.1 -file path=usr/share/man/man4/holidays.4 -file path=usr/share/man/man8/acct.8 -file path=usr/share/man/man8/acctcms.8 -file path=usr/share/man/man8/acctcon.8 -file path=usr/share/man/man8/acctmerg.8 -file path=usr/share/man/man8/acctprc.8 -file path=usr/share/man/man8/acctsh.8 -file path=usr/share/man/man8/fwtmp.8 -file path=usr/share/man/man8/runacct.8 -file path=usr/share/man/man8/sar.8 -file path=var/spool/cron/crontabs/sys group=sys mode=0600 preserve=true -license cr_ATT license=cr_ATT -license cr_Sun license=cr_Sun -license lic_CDDL license=lic_CDDL -link path=usr/bin/sar target=../sbin/sar +set name=pkg.obsolete value=true