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