xref: /openbsd-src/usr.sbin/sa/sa.8 (revision f4bb029c095c50c4f4f30e862ee473c0dd260898)
1*f4bb029cSjsg.\"	$OpenBSD: sa.8,v 1.22 2020/02/08 01:38:48 jsg Exp $
2df930be7Sderaadt.\"
3df930be7Sderaadt.\" Copyright (c) 1994 Christopher G. Demetriou
4df930be7Sderaadt.\" All rights reserved.
5df930be7Sderaadt.\"
6df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without
7df930be7Sderaadt.\" modification, are permitted provided that the following conditions
8df930be7Sderaadt.\" are met:
9df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright
10df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer.
11df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright
12df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer in the
13df930be7Sderaadt.\"    documentation and/or other materials provided with the distribution.
14df930be7Sderaadt.\" 3. All advertising materials mentioning features or use of this software
15df930be7Sderaadt.\"    must display the following acknowledgement:
16df930be7Sderaadt.\"      This product includes software developed by Christopher G. Demetriou.
17df930be7Sderaadt.\" 3. The name of the author may not be used to endorse or promote products
18df930be7Sderaadt.\"    derived from this software without specific prior written permission
19df930be7Sderaadt.\"
20df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21df930be7Sderaadt.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22df930be7Sderaadt.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23df930be7Sderaadt.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24df930be7Sderaadt.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25df930be7Sderaadt.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26df930be7Sderaadt.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27df930be7Sderaadt.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28df930be7Sderaadt.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29df930be7Sderaadt.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30df930be7Sderaadt.\"
31*f4bb029cSjsg.Dd $Mdocdate: February 8 2020 $
32df930be7Sderaadt.Dt SA 8
3319244f19Smichaels.Os
34df930be7Sderaadt.Sh NAME
35df930be7Sderaadt.Nm sa
36df930be7Sderaadt.Nd print system accounting statistics
37df930be7Sderaadt.Sh SYNOPSIS
3843399070Saaron.Nm sa
39f3b80c16Sjmc.Op Fl abcDdfijKklmnqrstu
40df930be7Sderaadt.Op Fl v Ar cutoff
41df930be7Sderaadt.Op Ar
42df930be7Sderaadt.Sh DESCRIPTION
43df930be7SderaadtThe
44885abdb2Saaron.Nm
45df930be7Sderaadtutility reports on, cleans up,
46df930be7Sderaadtand generally maintains system
47df930be7Sderaadtaccounting files.
4857c4edc3SjmcSee
4957c4edc3Sjmc.Xr accton 8
5057c4edc3Sjmcfor details on enabling system accounting.
51df930be7Sderaadt.Pp
52885abdb2Saaron.Nm
53df930be7Sderaadtis able to condense the information in
54df930be7Sderaadt.Pa /var/account/acct
55df930be7Sderaadtinto the summary files
56df930be7Sderaadt.Pa /var/account/savacct
57df930be7Sderaadtand
58df930be7Sderaadt.Pa /var/account/usracct ,
59df930be7Sderaadtwhich contain system statistics according
60885abdb2Saaronto command name and login ID, respectively.
61df930be7SderaadtThis condensation is desirable because on a
62df930be7Sderaadtlarge system,
63df930be7Sderaadt.Pa /var/account/acct
64df930be7Sderaadtcan grow by hundreds of blocks per day.
65df930be7SderaadtThe summary files are normally read before
66df930be7Sderaadtthe accounting file, so that reports include
67df930be7Sderaadtall available information.
68df930be7Sderaadt.Pp
69df930be7SderaadtIf file names are supplied, they are read instead of
70ea3437b0Sderaadt.Pa /var/account/acct .
71df930be7SderaadtAfter each file is read, if the summary
72df930be7Sderaadtfiles are being updated, an updated summary will
73cdbdb68aSaaronbe saved to disk.
74cdbdb68aSaaronOnly one report is printed, after the last file is processed.
75df930be7Sderaadt.Pp
76df930be7SderaadtThe labels used in the output indicate the following, except
77df930be7Sderaadtwhere otherwise specified by individual options:
78885abdb2Saaron.Pp
79f3b80c16Sjmc.Bl -tag -width k*sec -compact -offset indent
80df930be7Sderaadt.It Dv avio
81885abdb2SaaronAverage number of I/O operations per execution.
82df930be7Sderaadt.It Dv cp
83885abdb2SaaronSum of user and system time, in minutes.
84df930be7Sderaadt.It Dv cpu
85df930be7SderaadtSame as
86885abdb2Saaron.Dv cp .
87df930be7Sderaadt.It Dv k
88885abdb2SaaronCPU time averaged core usage, in 1k units.
89df930be7Sderaadt.It Dv k*sec
90885abdb2SaaronCPU storage integral, in 1k-core seconds.
91df930be7Sderaadt.It Dv re
92885abdb2SaaronReal time, in minutes.
93df930be7Sderaadt.It Dv s
94885abdb2SaaronSystem time, in minutes.
95df930be7Sderaadt.It Dv tio
96885abdb2SaaronTotal number of I/O operations.
97df930be7Sderaadt.It Dv u
98885abdb2SaaronUser time, in minutes.
99df930be7Sderaadt.El
100df930be7Sderaadt.Pp
1018cf461a5SaaronThe options are as follows:
102df930be7Sderaadt.Bl -tag -width Ds
103df930be7Sderaadt.It Fl a
104df930be7SderaadtList all command names, including those containing unprintable
105cdbdb68aSaaroncharacters and those used only once.
106cdbdb68aSaaronBy default,
107885abdb2Saaron.Nm
108df930be7Sderaadtplaces all names containing unprintable characters and
109885abdb2Saaronthose used only once under the name
110885abdb2Saaron.Dq ***other .
111df930be7Sderaadt.It Fl b
112df930be7SderaadtIf printing command statistics, sort output by the sum of user and system
113df930be7Sderaadttime divided by number of calls.
114df930be7Sderaadt.It Fl c
115df930be7SderaadtIn addition to the number of calls and the user, system and real times
116df930be7Sderaadtfor each command, print their percentage of the total over all commands.
117f3b80c16Sjmc.It Fl D
118f3b80c16SjmcIf printing command statistics, sort and print by the total number
119f3b80c16Sjmcof disk I/O operations.
120df930be7Sderaadt.It Fl d
121df930be7SderaadtIf printing command statistics, sort by the average number of disk
122cdbdb68aSaaronI/O operations.
123cdbdb68aSaaronIf printing user statistics, print the average number of
124df930be7Sderaadtdisk I/O operations per user.
125df930be7Sderaadt.It Fl f
126df930be7SderaadtForce no interactive threshold comparison with the
127df930be7Sderaadt.Fl v
128df930be7Sderaadtoption.
129df930be7Sderaadt.It Fl i
130df930be7SderaadtDo not read in the summary files.
131df930be7Sderaadt.It Fl j
132df930be7SderaadtInstead of the total minutes per category, give seconds per call.
133f3b80c16Sjmc.It Fl K
134f3b80c16SjmcIf printing command statistics, print and sort by the CPU-storage integral.
135df930be7Sderaadt.It Fl k
136885abdb2SaaronIf printing command statistics, sort by the CPU time average memory
137cdbdb68aSaaronusage.
138cdbdb68aSaaronIf printing user statistics, print the CPU time average memory usage.
139df930be7Sderaadt.It Fl l
140df930be7SderaadtSeparate system and user time; normally they are combined.
141df930be7Sderaadt.It Fl m
1425b137761SjmcPrint per-user statistics rather than per-command statistics, including
1435b137761Sjmcthe user name, the number of commands invoked, total CPU time used
1445b137761Sjmc(in minutes), total number of I/O operations, and CPU storage integral
1455b137761Sjmcfor each user.
1465b137761SjmcIf this option is specified, only the
1475b137761Sjmc.Fl b ,
1485b137761Sjmc.Fl d ,
1495b137761Sjmc.Fl i ,
1505b137761Sjmc.Fl k ,
1515b137761Sjmc.Fl q ,
1525b137761Sjmcand
1535b137761Sjmc.Fl s
1545b137761Sjmcflags are honored.
155df930be7Sderaadt.It Fl n
156df930be7SderaadtSort by number of calls.
157df930be7Sderaadt.It Fl q
158df930be7SderaadtCreate no output other than error messages.
159df930be7Sderaadt.It Fl r
160df930be7SderaadtReverse order of sort.
161df930be7Sderaadt.It Fl s
162df930be7SderaadtTruncate the accounting files when done and merge their data
163df930be7Sderaadtinto the summary files.
164df930be7Sderaadt.It Fl t
165df930be7SderaadtFor each command, report the ratio of real time to the sum
166885abdb2Saaronof user and system CPU times.
167885abdb2SaaronIf the CPU time is too small to report,
168885abdb2Saaron.Dq *ignore*
169885abdb2Saaronappears in this field.
170df930be7Sderaadt.It Fl u
1715b137761SjmcSuperseding all other flags (except
1725b137761Sjmc.Fl q ) ,
1735b137761Sjmcfor each entry in the accounting file print the user ID,
1745b137761Sjmctotal seconds of CPU usage,
1755b137761Sjmctotal memory usage, number of I/O operations performed,
1765b137761Sjmcand command name.
177df930be7Sderaadt.It Fl v Ar cutoff
178df930be7SderaadtFor each command used
179df930be7Sderaadt.Ar cutoff
180df930be7Sderaadttimes or fewer, print the command name and await a reply
181cdbdb68aSaaronfrom the terminal.
182cdbdb68aSaaronIf the reply begins with
183885abdb2Saaron.Dq y ,
184885abdb2Saaronadd the command to the category
185885abdb2Saaron.Dq **junk** .
186885abdb2SaaronThis flag is used to strip garbage from the report.
187df930be7Sderaadt.El
188df930be7Sderaadt.Pp
1895b137761SjmcBy default, per-command statistics are printed and show
1905b137761Sjmcthe number of calls, the total elapsed time in minutes,
1915b137761Sjmctotal CPU and user time in minutes, average number of I/O operations,
1925b137761Sjmcand CPU time averaged core usage.
193472d1d5fSzhukChildren which have not yet called
194472d1d5fSzhuk.Xr execve 2
1955b137761Sjmchave
196472d1d5fSzhuk.Sq *
197472d1d5fSzhukappended to their command names.
198df930be7Sderaadt.Sh FILES
199df930be7Sderaadt.Bl -tag -width /var/account/usracct -compact
200df930be7Sderaadt.It Pa /var/account/acct
201df930be7Sderaadtraw accounting data file
202df930be7Sderaadt.It Pa /var/account/savacct
203df930be7Sderaadtper-command accounting summary database
204df930be7Sderaadt.It Pa /var/account/usracct
205df930be7Sderaadtper-user accounting summary database
206df930be7Sderaadt.El
207741b6f30Sjmc.Sh EXIT STATUS
208741b6f30Sjmc.Ex -std sa
209df930be7Sderaadt.Sh SEE ALSO
210885abdb2Saaron.Xr lastcomm 1 ,
211df930be7Sderaadt.Xr acct 5 ,
212885abdb2Saaron.Xr ac 8 ,
213885abdb2Saaron.Xr accton 8
2149d0b46bcSjmc.Sh HISTORY
2159d0b46bcSjmc.Nm
216*f4bb029cSjsgfirst appeared in
217*f4bb029cSjsg.At v5 .
218*f4bb029cSjsg.Nm
219*f4bb029cSjsgwas rewritten for
2209d0b46bcSjmc.Nx 0.9a
2219d0b46bcSjmcfrom the specification provided by various systems' manual pages.
2229d0b46bcSjmc.Sh AUTHORS
22344e68d47Sschwarze.An Chris G. Demetriou Aq Mt cgd@postgres.berkeley.edu
224df930be7Sderaadt.Sh CAVEATS
225df930be7SderaadtWhile the behavior of the options in this version of
226885abdb2Saaron.Nm
227df930be7Sderaadtwas modeled after the original version, there are some intentional
228cdbdb68aSaarondifferences and undoubtedly some unintentional ones as well.
229cdbdb68aSaaronIn particular, the
230df930be7Sderaadt.Fl q
231df930be7Sderaadtoption has been added, and the
232df930be7Sderaadt.Fl m
233df930be7Sderaadtoption now understands more options than it used to.
234df930be7Sderaadt.Pp
235df930be7SderaadtThe formats of the summary files created by this version of
236885abdb2Saaron.Nm
237ce9dbd65Sjmcare very different than those used by the original version.
238df930be7SderaadtThis is not considered a problem, however, because the accounting record
2397f4b41deSjmcformat has changed as well (since user IDs are now 32 bits).
2409d0b46bcSjmc.Sh BUGS
2419d0b46bcSjmcThe number of options to this program is absurd, especially considering
2429d0b46bcSjmcthat there's not much logic behind their lettering.
2439d0b46bcSjmc.Pp
2449d0b46bcSjmcThe field labels should be more consistent.
2459d0b46bcSjmc.Pp
2469d0b46bcSjmcOpenBSD's VM system does not record the CPU storage integral.
247