1.\" 2.\" Copyright (c) 1994 Christopher G. Demetriou 3.\" All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. All advertising materials mentioning features or use of this software 14.\" must display the following acknowledgement: 15.\" This product includes software developed by Christopher G. Demetriou. 16.\" 3. The name of the author may not be used to endorse or promote products 17.\" derived from this software without specific prior written permission 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29.\" 30.\" $FreeBSD$ 31.\" 32.Dd February 25, 1994 33.Dt SA 8 34.Os 35.Sh NAME 36.Nm sa 37.Nd print system accounting statistics 38.Sh SYNOPSIS 39.Nm 40.Op Fl abcdDfijkKlmnqrstu 41.Op Fl v Ar cutoff 42.Op Ar 43.Sh DESCRIPTION 44The 45.Nm 46utility reports on, cleans up, 47and generally maintains system 48accounting files. 49.Pp 50The 51.Nm 52utility is able to condense the information in 53.Pa /var/account/acct 54into the summary files 55.Pa /var/account/savacct 56and 57.Pa /var/account/usracct , 58which contain system statistics according 59to command name and login id, respectively. 60This condensation is desirable because on a 61large system, 62.Pa /var/account/acct 63can grow by hundreds of blocks per day. 64The summary files are normally read before 65the accounting file, so that reports include 66all available information. 67.Pp 68If file names are supplied, they are read instead of 69.Pa /var/account/acct . 70After each file is read, if the summary 71files are being updated, an updated summary will 72be saved to disk. Only one report is printed, 73after the last file is processed. 74.Pp 75The labels used in the output indicate the following, except 76where otherwise specified by individual options: 77.Bl -tag -width k*sec 78.It Dv avio 79Average number of I/O operations per execution 80.It Dv cp 81Sum of user and system time, in minutes 82.It Dv cpu 83Same as 84.Dv cp 85.It Dv k 86CPU-time averaged core usage, in 1k units 87.It Dv k*sec 88CPU storage integral, in 1k-core seconds 89.It Dv re 90Real time, in minutes 91.It Dv s 92System time, in minutes 93.It Dv tio 94Total number of I/O operations 95.It Dv u 96User time, in minutes 97.El 98.Pp 99The options to 100.Nm 101are: 102.Bl -tag -width Ds 103.It Fl a 104List all command names, including those containing unprintable 105characters and those used only once. By default, 106.Nm 107places all names containing unprintable characters and 108those used only once under the name ``***other''. 109.It Fl b 110If printing command statistics, sort output by the sum of user and system 111time divided by number of calls. 112.It Fl c 113In addition to the number of calls and the user, system and real times 114for each command, print their percentage of the total over all commands. 115.It Fl d 116If printing command statistics, sort by the average number of disk 117I/O operations. If printing user statistics, print the average number of 118disk I/O operations per user. 119.It Fl D 120If printing command statistics, sort and print by the total number 121of disk I/O operations. 122.It Fl f 123Force no interactive threshold comparison with the 124.Fl v 125option. 126.It Fl i 127Do not read in the summary files. 128.It Fl j 129Instead of the total minutes per category, give seconds per call. 130.It Fl k 131If printing command statistics, sort by the cpu-time average memory 132usage. If printing user statistics, print the cpu-time average 133memory usage. 134.It Fl K 135If printing command statistics, print and sort by the cpu-storage integral. 136.It Fl l 137Separate system and user time; normally they are combined. 138.It Fl m 139Print per-user statistics rather than per-command statistics. 140.It Fl n 141Sort by number of calls. 142.It Fl q 143Create no output other than error messages. 144.It Fl r 145Reverse order of sort. 146.It Fl s 147Truncate the accounting files when done and merge their data 148into the summary files. 149.It Fl t 150For each command, report the ratio of real time to the sum 151of user and system cpu times. 152If the cpu time is too small to report, ``*ignore*'' appears in 153this field. 154.It Fl u 155Superseding all other flags, for each entry 156in the accounting file, print the user ID, total seconds of cpu usage, 157total memory usage, number of I/O operations performed, and 158command name. 159.It Fl v Ar cutoff 160For each command used 161.Ar cutoff 162times or fewer, print the command name and await a reply 163from the terminal. If the reply begins with ``y'', add 164the command to the category ``**junk**''. This flag is 165used to strip garbage from the report. 166.El 167.Pp 168By default, per-command statistics will be printed. The number of 169calls, the total elapsed time in minutes, total cpu and user time 170in minutes, average number of I/O operations, and CPU-time 171averaged core usage will be printed. If the 172.Fl m 173option is specified, per-user statistics will be printed, including 174the user name, the number of commands invoked, total cpu time used 175(in minutes), total number of I/O operations, and CPU storage integral 176for each user. If the 177.Fl u 178option is specified, the uid, user and system time (in seconds), 179CPU storage integral, I/O usage, and command name will be printed 180for each entry in the accounting data file. 181.Pp 182If the 183.Fl u 184flag is specified, all flags other than 185.Fl q 186are ignored. If the 187.Fl m 188flag is specified, only the 189.Fl b , 190.Fl d , 191.Fl i , 192.Fl k , 193.Fl q , 194and 195.Fl s 196flags are honored. 197.Sh DIAGNOSTICS 198.Ex -std 199.Sh FILES 200.Bl -tag -width /var/account/usracct -compact 201.It Pa /var/account/acct 202raw accounting data file 203.It Pa /var/account/savacct 204per-command accounting summary database 205.It Pa /var/account/usracct 206per-user accounting summary database 207.El 208.Sh SEE ALSO 209.Xr lastcomm 1 , 210.Xr acct 5 , 211.Xr ac 8 , 212.Xr accton 8 213.Sh BUGS 214The number of options to this program is absurd, especially considering 215that there's not much logic behind their lettering. 216.Pp 217The field labels should be more consistent. 218.Pp 219The VM system does not record the CPU storage integral. 220.Sh CAVEATS 221While the behavior of the options in this version of 222.Nm 223was modeled after the original version, there are some intentional 224differences and undoubtedly some unintentional ones as well. In 225particular, the 226.Fl q 227option has been added, and the 228.Fl m 229option now understands more options than it used to. 230.Pp 231The formats of the summary files created by this version of 232.Nm 233are very different from the those used by the original version. 234This is not considered a problem, however, because the accounting record 235format has changed as well (since user ids are now 32 bits). 236.Sh AUTHORS 237.An Chris G. Demetriou Aq cgd@postgres.berkeley.edu 238