xref: /openbsd/usr.sbin/sa/sa.8 (revision e5dd7070)
1.\"	$OpenBSD: sa.8,v 1.22 2020/02/08 01:38:48 jsg 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: February 8 2020 $
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, including
143the user name, the number of commands invoked, total CPU time used
144(in minutes), total number of I/O operations, and CPU storage integral
145for each user.
146If this option is specified, only the
147.Fl b ,
148.Fl d ,
149.Fl i ,
150.Fl k ,
151.Fl q ,
152and
153.Fl s
154flags are honored.
155.It Fl n
156Sort by number of calls.
157.It Fl q
158Create no output other than error messages.
159.It Fl r
160Reverse order of sort.
161.It Fl s
162Truncate the accounting files when done and merge their data
163into the summary files.
164.It Fl t
165For each command, report the ratio of real time to the sum
166of user and system CPU times.
167If the CPU time is too small to report,
168.Dq *ignore*
169appears in this field.
170.It Fl u
171Superseding all other flags (except
172.Fl q ) ,
173for each entry in the accounting file print the user ID,
174total seconds of CPU usage,
175total memory usage, number of I/O operations performed,
176and command name.
177.It Fl v Ar cutoff
178For each command used
179.Ar cutoff
180times or fewer, print the command name and await a reply
181from the terminal.
182If the reply begins with
183.Dq y ,
184add the command to the category
185.Dq **junk** .
186This flag is used to strip garbage from the report.
187.El
188.Pp
189By default, per-command statistics are printed and show
190the number of calls, the total elapsed time in minutes,
191total CPU and user time in minutes, average number of I/O operations,
192and CPU time averaged core usage.
193Children which have not yet called
194.Xr execve 2
195have
196.Sq *
197appended to their command names.
198.Sh FILES
199.Bl -tag -width /var/account/usracct -compact
200.It Pa /var/account/acct
201raw accounting data file
202.It Pa /var/account/savacct
203per-command accounting summary database
204.It Pa /var/account/usracct
205per-user accounting summary database
206.El
207.Sh EXIT STATUS
208.Ex -std sa
209.Sh SEE ALSO
210.Xr lastcomm 1 ,
211.Xr acct 5 ,
212.Xr ac 8 ,
213.Xr accton 8
214.Sh HISTORY
215.Nm
216first appeared in
217.At v5 .
218.Nm
219was rewritten for
220.Nx 0.9a
221from the specification provided by various systems' manual pages.
222.Sh AUTHORS
223.An Chris G. Demetriou Aq Mt cgd@postgres.berkeley.edu
224.Sh CAVEATS
225While the behavior of the options in this version of
226.Nm
227was modeled after the original version, there are some intentional
228differences and undoubtedly some unintentional ones as well.
229In particular, the
230.Fl q
231option has been added, and the
232.Fl m
233option now understands more options than it used to.
234.Pp
235The formats of the summary files created by this version of
236.Nm
237are very different than those used by the original version.
238This is not considered a problem, however, because the accounting record
239format has changed as well (since user IDs are now 32 bits).
240.Sh BUGS
241The number of options to this program is absurd, especially considering
242that there's not much logic behind their lettering.
243.Pp
244The field labels should be more consistent.
245.Pp
246OpenBSD's VM system does not record the CPU storage integral.
247