-
Notifications
You must be signed in to change notification settings - Fork 113
/
atop.h
250 lines (216 loc) · 6.45 KB
/
atop.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
** 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 describing miscellaneous constants and function-prototypes.
** ================================================================
** 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.
*/
#ifndef __ATOP__
#define __ATOP__
#include <time.h>
#define EQ 0
#define SECONDSINDAY 86400
#define RAWNAMESZ 256
/*
** memory-size formatting possibilities
*/
#define BFORMAT 0
#define KBFORMAT 1
#define KBFORMAT_INT 2
#define MBFORMAT 3
#define MBFORMAT_INT 4
#define GBFORMAT 5
#define GBFORMAT_INT 6
#define TBFORMAT 7
#define TBFORMAT_INT 8
#define PBFORMAT 9
#define PBFORMAT_INT 10
#define EBFORMAT 11
#define EBFORMAT_INT 12
#define OVFORMAT 13
typedef long long count_t;
struct tstat;
struct devtstat;
struct sstat;
struct cgchainer;
struct netpertask;
/*
** miscellaneous flags
*/
#define RRBOOT 0x0001
#define RRLAST 0x0002
#define RRNETATOP 0x0004
#define RRNETATOPD 0x0008
#define RRACCTACTIVE 0x0010
#define RRIOSTAT 0x0020
#define RRCONTAINERSTAT 0x0040
#define RRGPUSTAT 0x0080
#define RRCGRSTAT 0x0100
#define MAXHANDLERS 10
struct handler {
char (*handle_sample) (time_t, int,
struct devtstat *, struct sstat *,
struct cgchainer *, int, int, int,
unsigned int, char);
};
/*
** external values
*/
extern struct utsname utsname;
extern int utsnodenamelen;
extern time_t pretime;
extern time_t curtime;
extern unsigned long interval;
extern unsigned long sampcnt;
extern char screen;
extern int fdinotify;
extern pid_t twinpid;
extern int linelen;
extern char acctreason;
extern char deviatonly;
extern char usecolors;
extern char threadview;
extern char calcpss;
extern char getwchan;
extern char irawname[];
extern char orawname[];
extern char rawreadflag;
extern char idnamesuppress;
extern char rmspaces;
extern time_t begintime, endtime, cursortime; // epoch or time in day
extern char flaglist[];
extern struct handler handlers[];
extern char displaymode;
extern char barmono;
extern int osrel;
extern int osvers;
extern int ossub;
extern unsigned short hertz;
extern unsigned int pagesize;
extern unsigned int pidwidth;
extern unsigned int nrgpus;
extern int supportflags;
extern int cpubadness;
extern int membadness;
extern int swpbadness;
extern int dskbadness;
extern int netbadness;
extern int pagbadness;
extern int almostcrit;
/*
** bit-values for supportflags
*/
#define ACCTACTIVE 0x00000001
#define IOSTAT 0x00000004
#define NETATOP 0x00000010
#define NETATOPD 0x00000020
#define CONTAINERSTAT 0x00000040
#define GPUSTAT 0x00000080
#define CGROUPV2 0x00000100
#define NETATOPBPF 0x00001000
/*
** in rawlog file, the four least significant bits
** are moved to the per-sample flags and therefor dummy
** in the support flags of the general header
*/
#define RAWLOGNG (ACCTACTIVE|IOSTAT|NETATOP|NETATOPD)
/*
** structure containing the start addresses of functions for visualization
*/
char generic_samp (time_t, int,
struct devtstat *, struct sstat *,
struct cgchainer *, int, int,
int, unsigned int, char);
void generic_error(const char *, ...);
void generic_end (void);
void generic_usage(void);
/*
** miscellaneous prototypes
*/
int atopsar(int, char *[]);
char *convtime(time_t, char *);
char *convdate(time_t, char *);
int getbranchtime(char *, time_t *);
time_t normalize_epoch(time_t, long);
char *val2valstr(count_t, char *, int, int, int);
char *val2memstr(count_t, char *, int, int, int);
char *val2cpustr(count_t, char *);
char *val2Hzstr(count_t, char *);
int val2elapstr(int, char *);
char *uid2name(uid_t);
char *gid2name(gid_t);
int compcpu(const void *, const void *);
int compdsk(const void *, const void *);
int compmem(const void *, const void *);
int compnet(const void *, const void *);
int compgpu(const void *, const void *);
int compusr(const void *, const void *);
int compnam(const void *, const void *);
int compcon(const void *, const void *);
int cpucompar (const void *, const void *);
int gpucompar (const void *, const void *);
int diskcompar(const void *, const void *);
int intfcompar(const void *, const void *);
int ifbcompar(const void *, const void *);
int nfsmcompar(const void *, const void *);
int contcompar(const void *, const void *);
int memnumacompar(const void *, const void *);
int cpunumacompar(const void *, const void *);
int llccompar(const void *, const void *);
int rawread(void);
char rawwrite (time_t, int,
struct devtstat *, struct sstat *,
struct cgchainer *, int, int,
int, unsigned int, char);
int numeric(char *);
void getalarm(int);
unsigned long long getboot(void);
char *getstrvers(void);
unsigned short getnumvers(void);
void ptrverify(const void *, const char *, ...);
void mcleanstop(int, const char *, ...);
void cleanstop(int);
int getpidwidth(void);
void prusage(char *);
int rootprivs(void);
int droprootprivs(void);
void regainrootprivs(void);
FILE *fopen_tryroot(const char *, const char *);
void netatop_ipopen(void);
void netatop_probe(void);
void netatop_signoff(void);
void netatop_gettask(pid_t, char, struct tstat *);
unsigned int netatop_exitstore(void);
void netatop_exiterase(void);
void netatop_exithash(char);
void netatop_exitfind(unsigned long, struct tstat *, struct tstat *);
void netatop_bpf_ipopen(void);
void netatop_bpf_probe(void);
void netatop_bpf_gettask(void);
void netatop_bpf_exitfind(unsigned long, struct tstat *, struct tstat *);
void set_oom_score_adj(void);
int run_in_guest(void);
void getusr1(int), getusr2(int);
void do_pacctdir(char *, char *);
void do_atopsarflags(char *, char *);
int netlink_open(void);
int netlink_recv(int, int);
int getutsname(struct tstat *);
void resetutsname(void);
#endif