xref: /freebsd/share/man/man5/acct.5 (revision 6137b5f7b8c183ee8806d79b3f1d8e5e3ddb3df3)
1.\" Copyright (c) 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd February 13, 2017
29.Dt ACCT 5
30.Os
31.Sh NAME
32.Nm acct
33.Nd execution accounting file
34.Sh SYNOPSIS
35.In sys/types.h
36.In sys/acct.h
37.Sh DESCRIPTION
38The kernel maintains the following
39.Fa acct
40information structure for all
41processes.
42If a process terminates, and accounting is enabled,
43the kernel calls the
44.Xr acct 2
45function call to prepare and append the record
46to the accounting file.
47.Bd -literal
48#define AC_COMM_LEN 16
49
50/*
51 * Accounting structure version 3 (current).
52 * The first byte is always zero.
53 * Time units are microseconds.
54 */
55
56struct acctv3 {
57	uint8_t  ac_zero;		/* zero identifies new version */
58	uint8_t  ac_version;		/* record version number */
59	uint16_t ac_len;		/* record length */
60
61	char	  ac_comm[AC_COMM_LEN];	/* command name */
62	float	  ac_utime;		/* user time */
63	float	  ac_stime;		/* system time */
64	float	  ac_etime;		/* elapsed time */
65	time_t	  ac_btime;		/* starting time */
66	uid_t	  ac_uid;		/* user id */
67	gid_t	  ac_gid;		/* group id */
68	float	  ac_mem;		/* average memory usage */
69	float	  ac_io;		/* count of IO blocks */
70	__dev_t   ac_tty;		/* controlling tty */
71
72	uint16_t ac_len2;		/* record length */
73	union {
74		uint32_t  ac_align;	/* force v1 compatible alignment */
75
76#define	AFORK	0x01			/* forked but not exec'ed */
77/* ASU is no longer supported */
78#define	ASU	0x02			/* used super-user permissions */
79#define	ACOMPAT	0x04			/* used compatibility mode */
80#define	ACORE	0x08			/* dumped core */
81#define	AXSIG	0x10			/* killed by a signal */
82#define ANVER	0x20			/* new record version */
83
84		uint8_t  ac_flag;	/* accounting flags */
85	} ac_trailer;
86
87#define ac_flagx ac_trailer.ac_flag
88};
89.Ed
90.Pp
91If a terminated process was created by an
92.Xr execve 2 ,
93the name of the executed file (at most ten characters of it)
94is saved in the field
95.Fa ac_comm
96and its status is saved by setting one of more of the following flags in
97.Fa ac_flag :
98.Dv AFORK ,
99.Dv ACOMPAT ,
100.Dv ACORE
101and
102.Dv ASIG .
103.Dv ASU
104is no longer supported.
105.Dv ANVER
106is always set in the above structure.
107.Sh SEE ALSO
108.Xr lastcomm 1 ,
109.Xr acct 2 ,
110.Xr execve 2 ,
111.Xr sa 8
112.Sh HISTORY
113A
114.Nm
115file format appeared in
116.At v7 .
117The current record format was introduced on May 2007.
118It is backwards compatible with the previous format,
119which is still documented in
120.In sys/acct.h
121and supported by
122.Xr lastcomm 1
123and
124.Xr sa 8 .
125