-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathacctproc.h
208 lines (194 loc) · 6.71 KB
/
acctproc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
** ATOP - System & Process Monitor
**
** The program 'atop' offers the possibility to view the activity of
** the system on system-level as well as process-level.
**
** Include-file for process-accounting functions.
** ================================================================
** Author: Gerlof Langeveld
** E-mail: [email protected]
** Date: November 1996
** LINUX-port: June 2000
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 2, or (at your option) any
** later version.
**
** This program is distributed in the hope that it will be useful, but
** WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU General Public License for more details.
*/
int acctswon(void);
void acctswoff(void);
int acctprocnt(void);
int acctphotoproc(struct tstat *, int);
void acctrepos(unsigned int);
/*
** maximum number of records to be read from process accounting file
** for one sample, to avoid that atop explodes and introduces OOM killing ....
**
** the maximum is based on a limit of 50 MiB extra memory (approx. 70000 procs)
*/
#define MAXACCTPROCS (50*1024*1024/sizeof(struct tstat))
/*
** preferred maximum size of process accounting file (200 MiB)
*/
#define ACCTMAXFILESZ (200*1024*1024)
#ifdef linux
/*
** alternative layout of accounting record if kernel-patch
** has been installed
*/
#include <linux/types.h>
typedef __u16 comp_t;
typedef __u32 comp2_t;
#elif defined(FREEBSD)
#include <sys/types.h>
#include <sys/acct.h>
typedef uint16_t comp_t;
typedef uint32_t comp2_t;
#define __u16 uint16_t
#define __u8 uint8_t
#define __u32 uint32_t
#define __64 uint64_t
#endif
#define ACCT_COMM 16
struct acct_atop
{
char ac_flag; /* Flags */
char ac_version; /* Always set to ACCT_VERSION */
__u32 ac_pid; /* Process ID */
__u32 ac_ppid; /* Parent Process ID */
__u16 ac_uid16; /* LSB of Real User ID */
__u16 ac_gid16; /* LSB of Real Group ID */
__u16 ac_tty; /* Control Terminal */
__u32 ac_btime; /* Process Creation Time */
comp_t ac_utime; /* User Time */
comp_t ac_stime; /* System Time */
comp_t ac_etime; /* Elapsed Time */
comp_t ac_mem; /* Virtual Memory */
comp_t ac_rss; /* Resident Memory */
comp_t ac_io; /* Chars Transferred */
comp_t ac_rw; /* Blocks Read or Written */
comp_t ac_bread; /* Blocks Read */
comp_t ac_bwrite; /* Blocks Written */
comp2_t ac_dskrsz; /* Cum. blocks read */
comp2_t ac_dskwsz; /* Cum. blocks written */
comp_t ac_tcpsnd; /* TCP send requests */
comp_t ac_tcprcv; /* TCP recv requests */
comp2_t ac_tcpssz; /* TCP cum. length */
comp2_t ac_tcprsz; /* TCP cum. length */
comp_t ac_udpsnd; /* UDP send requests */
comp_t ac_udprcv; /* UDP recv requests */
comp2_t ac_udpssz; /* UDP cum. length */
comp2_t ac_udprsz; /* UDP cum. length */
comp_t ac_rawsnd; /* RAW send requests */
comp_t ac_rawrcv; /* RAW recv requests */
comp_t ac_minflt; /* Minor Pagefaults */
comp_t ac_majflt; /* Major Pagefaults */
comp_t ac_swaps; /* Number of Swaps */
/* m68k had no padding here. */
#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
__u16 ac_ahz; /* AHZ */
#endif
__u32 ac_exitcode; /* Exitcode */
char ac_comm[ACCT_COMM + 1]; /* Command Name */
__u8 ac_etime_hi; /* Elapsed Time MSB */
__u16 ac_etime_lo; /* Elapsed Time LSB */
__u32 ac_uid; /* Real User ID */
__u32 ac_gid; /* Real Group ID */
};
#ifdef linux
/*
** default layout of accounting record
** (copied from /usr/src/linux/include/linux/acct.h)
*/
struct acct
{
char ac_flag; /* Flags */
char ac_version; /* Always set to ACCT_VERSION */
/* for binary compatibility back until 2.0 */
__u16 ac_uid16; /* LSB of Real User ID */
__u16 ac_gid16; /* LSB of Real Group ID */
__u16 ac_tty; /* Control Terminal */
__u32 ac_btime; /* Process Creation Time */
comp_t ac_utime; /* User Time */
comp_t ac_stime; /* System Time */
comp_t ac_etime; /* Elapsed Time */
comp_t ac_mem; /* Average Memory Usage */
comp_t ac_io; /* Chars Transferred */
comp_t ac_rw; /* Blocks Read or Written */
comp_t ac_minflt; /* Minor Pagefaults */
comp_t ac_majflt; /* Major Pagefaults */
comp_t ac_swaps; /* Number of Swaps */
/* m68k had no padding here. */
#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
__u16 ac_ahz; /* AHZ */
#endif
__u32 ac_exitcode; /* Exitcode */
char ac_comm[ACCT_COMM + 1]; /* Command Name */
__u8 ac_etime_hi; /* Elapsed Time MSB */
__u16 ac_etime_lo; /* Elapsed Time LSB */
__u32 ac_uid; /* Real User ID */
__u32 ac_gid; /* Real Group ID */
};
#elif defined(FREEBSD)
// copied from acct.h, probably better not to do this
struct acct {
uint8_t ac_zero; /* zero identifies new version */
uint8_t ac_version; /* record version number */
uint16_t ac_len; /* record length */
char ac_comm[AC_COMM_LEN]; /* command name */
float ac_utime; /* user time */
float ac_stime; /* system time */
float ac_etime; /* elapsed time */
time_t ac_btime; /* starting time */
uid_t ac_uid; /* user id */
gid_t ac_gid; /* group id */
float ac_mem; /* average memory usage */
float ac_io; /* count of IO blocks */
__dev_t ac_tty; /* controlling tty */
uint16_t ac_len2; /* record length */
union {
__dev_t ac_align; /* force v1 compatible alignment */
#define AFORK 0x01 /* forked but not exec'ed */
/* ASU is no longer supported */
#define ASU 0x02 /* used super-user permissions */
#define ACOMPAT 0x04 /* used compatibility mode */
#define ACORE 0x08 /* dumped core */
#define AXSIG 0x10 /* killed by a signal */
#define ANVER 0x20 /* new record version */
uint8_t ac_flag; /* accounting flags */
} ac_trailer;
#define ac_flagx ac_trailer.ac_flag
};
#endif
struct acct_v3
{
char ac_flag; /* Flags */
char ac_version; /* Always set to ACCT_VERSION */
__u16 ac_tty; /* Control Terminal */
__u32 ac_exitcode; /* Exitcode */
__u32 ac_uid; /* Real User ID */
__u32 ac_gid; /* Real Group ID */
__u32 ac_pid; /* Process ID */
__u32 ac_ppid; /* Parent Process ID */
__u32 ac_btime; /* Process Creation Time */
#ifdef __KERNEL__
__u32 ac_etime; /* Elapsed Time */
#else
float ac_etime; /* Elapsed Time */
#endif
comp_t ac_utime; /* User Time */
comp_t ac_stime; /* System Time */
comp_t ac_mem; /* Average Memory Usage */
comp_t ac_io; /* Chars Transferred */
comp_t ac_rw; /* Blocks Read or Written */
comp_t ac_minflt; /* Minor Pagefaults */
comp_t ac_majflt; /* Major Pagefaults */
comp_t ac_swaps; /* Number of Swaps */
char ac_comm[ACCT_COMM]; /* Command Name */
};