xref: /freebsd/usr.sbin/sa/sa.8 (revision 3c4ba5f55438f7afd4f4b0b56f88f2bb505fd6a6)
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 14, 2020
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 P Ar file
42.Op Fl U Ar file
43.Op Fl v Ar cutoff
44.Op Ar
45.Sh DESCRIPTION
46The
47.Nm
48utility reports on, cleans up,
49and generally maintains system
50accounting files.
51.Pp
52The
53.Nm
54utility is able to condense the information in
55.Pa /var/account/acct
56into the summary files
57.Pa /var/account/savacct
58and
59.Pa /var/account/usracct ,
60which contain system statistics according
61to command name and login id, respectively.
62This condensation is desirable because on a
63large system,
64.Pa /var/account/acct
65can grow by hundreds of blocks per day.
66The summary files are normally read before
67the accounting file, so that reports include
68all available information.
69.Pp
70If file names are supplied, they are read instead of
71.Pa /var/account/acct .
72After each file is read, if the summary
73files are being updated, an updated summary will
74be saved to disk.
75Only one report is printed,
76after the last file is processed.
77.Pp
78The labels used in the output indicate the following, except
79where otherwise specified by individual options:
80.Bl -tag -width k*sec
81.It Dv avio
82Average number of I/O operations per execution
83.It Dv cp
84Sum of user and system time, in minutes
85.It Dv cpu
86Same as
87.Dv cp
88.It Dv k
89CPU-time averaged core usage, in 1k units
90.It Dv k*sec
91CPU storage integral, in 1k-core seconds
92.It Dv re
93Real time, in minutes
94.It Dv s
95System time, in minutes
96.It Dv tio
97Total number of I/O operations
98.It Dv u
99User time, in minutes
100.El
101.Pp
102The options to
103.Nm
104are:
105.Bl -tag -width Ds
106.It Fl a
107List all command names, including those containing unprintable
108characters and those used only once.
109By default,
110.Nm
111places all names containing unprintable characters and
112those used only once under the name ``***other''.
113.It Fl b
114If printing command statistics, sort output by the sum of user and system
115time divided by number of calls.
116.It Fl c
117In addition to the number of calls and the user, system and real times
118for each command, print their percentage of the total over all commands.
119.It Fl d
120If printing command statistics, sort by the average number of disk
121I/O operations.
122If printing user statistics, print the average number of
123disk I/O operations per user.
124.It Fl D
125If printing command statistics, sort and print by the total number
126of disk I/O operations.
127.It Fl f
128Force no interactive threshold comparison with the
129.Fl v
130option.
131.It Fl i
132Do not read in the summary files.
133.It Fl j
134Instead of the total minutes per category, give seconds per call.
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
139memory usage.
140.It Fl K
141If printing command statistics, print and sort by the cpu-storage integral.
142.It Fl l
143Separate system and user time; normally they are combined.
144.It Fl m
145Print per-user statistics rather than per-command statistics.
146.It Fl n
147Sort by number of calls.
148.It Fl P Ar file
149Use the specified
150.Ar file
151for accessing the per-command accounting summary database,
152instead of the default
153.Pa /var/account/savacct .
154.It Fl q
155Create no output other than error messages.
156.It Fl r
157Reverse order of sort.
158.It Fl s
159Truncate the accounting files when done and merge their data
160into the summary files.
161.It Fl t
162For each command, report the ratio of real time to the sum
163of user and system cpu times.
164If the cpu time is too small to report, ``*ignore*'' appears in
165this field.
166.It Fl U Ar file
167Use the specified
168.Ar file
169for accessing the per-user accounting summary database,
170instead of the default
171.Pa /var/account/usracct .
172.It Fl u
173Superseding all other flags, for each entry
174in the accounting file, print the user ID, total seconds of cpu usage,
175total memory usage, number of I/O operations performed, and
176command 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 ``y'', add
183the command to the category ``**junk**''.
184This flag is
185used to strip garbage from the report.
186.El
187.Pp
188By default, per-command statistics will be printed.
189The number of
190calls, the total elapsed time in minutes, total cpu and user time
191in minutes, average number of I/O operations, and CPU-time
192averaged core usage will be printed.
193If the
194.Fl m
195option is specified, per-user statistics will be printed, including
196the user name, the number of commands invoked, total cpu time used
197(in minutes), total number of I/O operations, and CPU storage integral
198for each user.
199If the
200.Fl u
201option is specified, the uid, user and system time (in seconds),
202CPU storage integral, I/O usage, and command name will be printed
203for each entry in the accounting data file.
204.Pp
205If the
206.Fl u
207flag is specified, all flags other than
208.Fl q
209are ignored.
210If the
211.Fl m
212flag is specified, only the
213.Fl b ,
214.Fl d ,
215.Fl i ,
216.Fl k ,
217.Fl q ,
218and
219.Fl s
220flags are honored.
221.Sh FILES
222.Bl -tag -width /var/account/usracct -compact
223.It Pa /var/account/acct
224raw accounting data file
225.It Pa /var/account/savacct
226per-command accounting summary database
227.It Pa /var/account/usracct
228per-user accounting summary database
229.El
230.Sh EXIT STATUS
231.Ex -std
232.Sh SEE ALSO
233.Xr lastcomm 1 ,
234.Xr acct 5 ,
235.Xr ac 8 ,
236.Xr accton 8
237.Sh HISTORY
238.Nm
239first appeared in
240.At v5 .
241.Nm
242was rewritten for
243.Nx 0.9a
244from the specification provided by various systems' manual pages.
245.Sh AUTHORS
246.An Chris G. Demetriou Aq Mt cgd@postgres.berkeley.edu
247.Sh CAVEATS
248While the behavior of the options in this version of
249.Nm
250was modeled after the original version, there are some intentional
251differences and undoubtedly some unintentional ones as well.
252In
253particular, the
254.Fl q
255option has been added, and the
256.Fl m
257option now understands more options than it used to.
258.Pp
259The formats of the summary files created by this version of
260.Nm
261are very different from the those used by the original version.
262This is not considered a problem, however, because the accounting record
263format has changed as well (since user ids are now 32 bits).
264.Sh BUGS
265The number of options to this program is absurd, especially considering
266that there is not much logic behind their lettering.
267.Pp
268The field labels should be more consistent.
269.Pp
270The VM system does not record the CPU storage integral.
271