xref: /netbsd/usr.sbin/sa/sa.8 (revision 6550d01e)
1.\" $NetBSD: sa.8,v 1.16 2004/02/13 10:17:29 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.  Only one report is printed,
75after the last file is processed.
76.Pp
77The labels used in the output indicate the following, except
78where otherwise specified by individual options:
79.Bl -tag -width k*sec
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 to
102.Nm
103are:
104.Bl -tag -width Ds
105.It Fl a
106List all command names, including those containing unprintable
107characters and those used only once.  By default,
108.Nm
109places all names containing unprintable characters and
110those used only once under the name ``***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 by the average number of disk
119I/O operations.  If printing user statistics, print the average number of
120disk I/O operations per user.
121.It Fl D
122If printing command statistics, sort and print by the total number
123of disk I/O operations.
124.It Fl f
125Force no interactive threshold comparison with the
126.Fl v
127option.
128.It Fl i
129Do not read in the summary files.
130.It Fl j
131Instead of the total minutes per category, give seconds per call.
132.It Fl k
133If printing command statistics, sort by the CPU-time average memory
134usage.  If printing user statistics, print the CPU-time average
135memory usage.
136.It Fl K
137If printing command statistics, print and sort by the CPU-storage integral.
138.It Fl l
139Separate system and user time; normally they are combined.
140.It Fl m
141Print per-user statistics rather than per-command statistics.
142.It Fl n
143Sort by number of calls.
144.It Fl q
145Create no output other than error messages.
146.It Fl r
147Reverse order of sort.
148.It Fl s
149Truncate the accounting files when done and merge their data
150into the summary files.
151.It Fl t
152For each command, report the ratio of real time to the sum
153of user and system CPU times.
154If the CPU time is too small to report, ``*ignore*'' appears in
155this field.
156.It Fl u
157Superseding all other flags, for each entry
158in the accounting file, print the user ID, total seconds of CPU usage,
159total memory usage, number of I/O operations performed, and
160command name.
161.It Fl v Ar cutoff
162For each command used
163.Ar cutoff
164times or fewer, print the command name and await a reply
165from the terminal.  If the reply begins with ``y'', add
166the command to the category ``**junk**''.  This flag is
167used to strip garbage from the report.
168.El
169.Pp
170By default, per-command statistics will be printed.  The number of
171calls, the total elapsed time in minutes, total CPU and user time
172in minutes, average number of I/O operations, and CPU-time
173averaged core usage will be printed.  If the
174.Fl m
175option is specified, per-user statistics will be printed, including
176the user name, the number of commands invoked, total CPU time used
177(in minutes), total number of I/O operations, and CPU storage integral
178for each user.  If the
179.Fl u
180option is specified, the uid, user and system time (in seconds),
181CPU storage integral, I/O usage, and command name will be printed
182for each entry in the accounting data file.
183.Pp
184If the
185.Fl u
186flag is specified, all flags other than
187.Fl q
188are ignored.  If the
189.Fl m
190flag is specified, only the
191.Fl b ,
192.Fl d ,
193.Fl i ,
194.Fl k ,
195.Fl q ,
196and
197.Fl s
198flags are honored.
199.Pp
200The
201.Nm
202utility exits 0 on success, and \*[Gt]0 if an error occurs.
203.Sh FILES
204.Bl -tag -width /var/account/usracct -compact
205.It Pa /var/account/acct
206raw accounting data file
207.It Pa /var/account/savacct
208per-command accounting summary database
209.It Pa /var/account/usracct
210per-user accounting summary database
211.El
212.Sh SEE ALSO
213.Xr lastcomm 1 ,
214.Xr acct 5 ,
215.Xr ac 8 ,
216.Xr accton 8
217.Sh HISTORY
218.Nm
219was written for
220.Nx 1.0
221from the specification provided by various systems' manual pages.
222Its date of origin is unknown to the author.
223.Sh AUTHORS
224.An Chris G. Demetriou
225.Aq cgd@postgres.berkeley.edu .
226.Sh BUGS
227The number of options to this program is absurd, especially considering
228that there's not much logic behind their lettering.
229.Pp
230The field labels should be more consistent.
231.Pp
232.Nx Ns 's
233VM system does not record the CPU storage integral.
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.  In
239particular, 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