xref: /netbsd-src/usr.sbin/sa/sa.8 (revision d16b7486a53dcb8072b60ec6fcb4373a2d0c27b7)
1.\" $NetBSD: sa.8,v 1.20 2017/07/04 07:12:18 wiz 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 for the
17.\"          NetBSD Project.  See http://www.NetBSD.org/ for
18.\"          information about NetBSD.
19.\" 4. The name of the author may not be used to endorse or promote products
20.\"    derived from this software without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32.\"
33.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
34.\"
35.Dd February 25, 1994
36.Dt SA 8
37.Os
38.Sh NAME
39.Nm sa
40.Nd print system accounting statistics
41.Sh SYNOPSIS
42.Nm
43.Op Fl abcdDfijkKlmnqrstu
44.Op Fl v Ar cutoff
45.Op Ar
46.Sh DESCRIPTION
47The
48.Nm
49utility reports on, cleans up,
50and generally maintains system
51accounting files.
52.Pp
53.Nm
54is 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 q
149Create no output other than error messages.
150.It Fl r
151Reverse order of sort.
152.It Fl s
153Truncate the accounting files when done and merge their data
154into the summary files.
155.It Fl t
156For each command, report the ratio of real time to the sum
157of user and system CPU times.
158If the CPU time is too small to report, ``*ignore*'' appears in
159this field.
160.It Fl u
161Superseding all other flags, for each entry
162in the accounting file, print the user ID, total seconds of CPU usage,
163total memory usage, number of I/O operations performed, and
164command name.
165.It Fl v Ar cutoff
166For each command used
167.Ar cutoff
168times or fewer, print the command name and await a reply
169from the terminal.
170If the reply begins with ``y'', add
171the command to the category ``**junk**''.
172This flag is
173used to strip garbage from the report.
174.El
175.Pp
176By default, per-command statistics will be printed.
177The number of
178calls, the total elapsed time in minutes, total CPU and user time
179in minutes, average number of I/O operations, and CPU-time
180averaged core usage will be printed.
181If the
182.Fl m
183option is specified, per-user statistics will be printed, including
184the user name, the number of commands invoked, total CPU time used
185(in minutes), total number of I/O operations, and CPU storage integral
186for each user.
187If the
188.Fl u
189option is specified, the uid, user and system time (in seconds),
190CPU storage integral, I/O usage, and command name will be printed
191for each entry in the accounting data file.
192.Pp
193If the
194.Fl u
195flag is specified, all flags other than
196.Fl q
197are ignored.
198If the
199.Fl m
200flag is specified, only the
201.Fl b ,
202.Fl d ,
203.Fl i ,
204.Fl k ,
205.Fl q ,
206and
207.Fl s
208flags are honored.
209.Sh FILES
210.Bl -tag -width /var/account/usracct -compact
211.It Pa /var/account/acct
212raw accounting data file
213.It Pa /var/account/savacct
214per-command accounting summary database
215.It Pa /var/account/usracct
216per-user accounting summary database
217.El
218.Sh EXIT STATUS
219.Ex -std sa
220.Sh SEE ALSO
221.Xr lastcomm 1 ,
222.Xr acct 5 ,
223.Xr ac 8 ,
224.Xr accton 8
225.Sh HISTORY
226.Nm
227was written for
228.Nx 1.0
229from the specification provided by various systems' manual pages.
230Its date of origin is unknown to the author.
231.Sh AUTHORS
232.An Chris G. Demetriou
233.Aq cgd@postgres.berkeley.edu .
234.Sh CAVEATS
235While the behavior of the options in this version of
236.Nm
237was modeled after the original version, there are some intentional
238differences and undoubtedly some unintentional ones as well.
239In particular, the
240.Fl q
241option has been added, and the
242.Fl m
243option now understands more options than it used to.
244.Pp
245The formats of the summary files created by this version of
246.Nm
247are very different than the those used by the original version.
248This is not considered a problem, however, because the accounting record
249format has changed as well (since user ids are now 32 bits).
250.Sh BUGS
251The number of options to this program is absurd, especially considering
252that there's not much logic behind their lettering.
253.Pp
254The field labels should be more consistent.
255.Pp
256.Nx Ns 's
257VM system does not record the CPU storage integral.
258