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