forked from Atoptool/atop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showlinux.h
369 lines (348 loc) · 13.2 KB
/
showlinux.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/*
** 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.
**
** This source-file contains the Linux-specific functions to calculate
** figures to be visualized.
** ==========================================================================
** Author: JC van Winkel - AT Computing, Nijmegen, Holland
** E-mail: jc@ATComputing.nl
** Date: November 2009
** --------------------------------------------------------------------------
** Copyright (C) 2009 JC van Winkel
**
** 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.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
** --------------------------------------------------------------------------
**
** $Log: showlinux.h,v $
** Initial revision
**
** Initial
**
*/
#define MAXITEMS 80 /* The maximum number of items per line */
/*
* structure for extra parameters for system related data
*/
typedef struct {
count_t totut;
count_t totst;
int nact;
int nproc;
int ntrun;
int ntslpi;
int ntslpu;
int nzomb;
int nexit;
int noverflow;
int avgval;
int nsecs;
count_t mstot;
count_t iotot;
struct perdsk *perdsk;
int index;
count_t cputot;
count_t percputot;
} extraparam;
/***************************************************************/
/*
* structure for system print-list
*/
typedef struct {
char *configname; // name as used to
// config print line
char* (*doconvert)(void *, void *, int, int *); // ptr to convert func
} sys_printdef;
/*
* structure for system print-list with priority
* in case of leck of screen space, lowest priority items will be
* removed first
*/
typedef struct
{
sys_printdef *f;
int prio;
} sys_printpair;
/*
** structure for process print-list
*/
typedef struct
{
char *head; // column header
char *configname; // name as used to config print line
char *(*doactiveconvert)(struct tstat *,int,int);
// pointer to conv function
// for active process
char *(*doexitconvert) (struct tstat *,int,int);
// pointer to conv function
// for exited process
int width; // required width
int varwidth; // width may grow (eg cmd params)
} proc_printdef;
typedef struct
{
proc_printdef *f;
int prio;
} proc_printpair;
void showsysline(sys_printpair* elemptr,
struct sstat* sstat, extraparam *extra,
char *labeltext, unsigned int badness);
void showhdrline(proc_printpair* elemptr, int curlist, int totlist,
char showorder, char autosort);
void showprocline(proc_printpair* elemptr, struct tstat *curstat,
double perc, int nsecs, int avgval);
extern sys_printdef *prcsyspdefs[];
extern sys_printdef *cpusyspdefs[];
extern sys_printdef *cpisyspdefs[];
extern sys_printdef *cplsyspdefs[];
extern sys_printdef *memsyspdefs[];
extern sys_printdef *swpsyspdefs[];
extern sys_printdef *pagsyspdefs[];
extern sys_printdef *dsksyspdefs[];
extern sys_printdef *nettranssyspdefs[];
extern sys_printdef *netnetsyspdefs[];
extern sys_printdef *netintfsyspdefs[];
extern sys_printdef syspdef_PRCSYS;
extern sys_printdef syspdef_PRCUSER;
extern sys_printdef syspdef_PRCNPROC;
extern sys_printdef syspdef_PRCNRUNNING;
extern sys_printdef syspdef_PRCNSLEEPING;
extern sys_printdef syspdef_PRCNDSLEEPING;
extern sys_printdef syspdef_PRCNZOMBIE;
extern sys_printdef syspdef_PRCCLONES;
extern sys_printdef syspdef_PRCNNEXIT;
extern sys_printdef syspdef_CPUSYS;
extern sys_printdef syspdef_CPUUSER;
extern sys_printdef syspdef_CPUIRQ;
extern sys_printdef syspdef_CPUIDLE;
extern sys_printdef syspdef_CPUWAIT;
extern sys_printdef syspdef_CPUISYS;
extern sys_printdef syspdef_CPUIUSER;
extern sys_printdef syspdef_CPUIIRQ;
extern sys_printdef syspdef_CPUIIDLE;
extern sys_printdef syspdef_CPUIWAIT;
extern sys_printdef syspdef_CPUISTEAL;
extern sys_printdef syspdef_CPUIFREQ;
extern sys_printdef syspdef_CPUFREQ;
extern sys_printdef syspdef_CPUSCALE;
extern sys_printdef syspdef_CPUISCALE;
extern sys_printdef syspdef_CPUSTEAL;
extern sys_printdef syspdef_CPUISTEAL;
extern sys_printdef syspdef_CPUGUEST;
extern sys_printdef syspdef_CPUIGUEST;
extern sys_printdef syspdef_CPUIPC;
extern sys_printdef syspdef_CPUIIPC;
extern sys_printdef syspdef_CPUCYCLE;
extern sys_printdef syspdef_CPUICYCLE;
extern sys_printdef syspdef_CPLAVG1;
extern sys_printdef syspdef_CPLAVG5;
extern sys_printdef syspdef_CPLAVG15;
extern sys_printdef syspdef_CPLCSW;
extern sys_printdef syspdef_CPLNUMCPU;
extern sys_printdef syspdef_CPLINTR;
extern sys_printdef syspdef_MEMTOT;
extern sys_printdef syspdef_MEMFREE;
extern sys_printdef syspdef_MEMCACHE;
extern sys_printdef syspdef_MEMDIRTY;
extern sys_printdef syspdef_MEMBUFFER;
extern sys_printdef syspdef_MEMSLAB;
extern sys_printdef syspdef_RECSLAB;
extern sys_printdef syspdef_SHMEM;
extern sys_printdef syspdef_SHMRSS;
extern sys_printdef syspdef_SHMSWP;
extern sys_printdef syspdef_VMWBAL;
extern sys_printdef syspdef_HUPTOT;
extern sys_printdef syspdef_HUPUSE;
extern sys_printdef syspdef_SWPTOT;
extern sys_printdef syspdef_SWPFREE;
extern sys_printdef syspdef_SWPCOMMITTED;
extern sys_printdef syspdef_SWPCOMMITLIM;
extern sys_printdef syspdef_PAGSCAN;
extern sys_printdef syspdef_PAGSTEAL;
extern sys_printdef syspdef_PAGSTALL;
extern sys_printdef syspdef_PAGSWIN;
extern sys_printdef syspdef_PAGSWOUT;
extern sys_printdef syspdef_CONTNAME;
extern sys_printdef syspdef_CONTNPROC;
extern sys_printdef syspdef_CONTCPU;
extern sys_printdef syspdef_CONTMEM;
extern sys_printdef syspdef_DSKNAME;
extern sys_printdef syspdef_DSKBUSY;
extern sys_printdef syspdef_DSKNREAD;
extern sys_printdef syspdef_DSKNWRITE;
extern sys_printdef syspdef_DSKMBPERSECWR;
extern sys_printdef syspdef_DSKMBPERSECRD;
extern sys_printdef syspdef_DSKKBPERWR;
extern sys_printdef syspdef_DSKKBPERRD;
extern sys_printdef syspdef_DSKAVQUEUE;
extern sys_printdef syspdef_DSKAVIO;
extern sys_printdef syspdef_NETTRANSPORT;
extern sys_printdef syspdef_NETTCPI;
extern sys_printdef syspdef_NETTCPO;
extern sys_printdef syspdef_NETTCPACTOPEN;
extern sys_printdef syspdef_NETTCPPASVOPEN;
extern sys_printdef syspdef_NETTCPRETRANS;
extern sys_printdef syspdef_NETTCPINERR;
extern sys_printdef syspdef_NETTCPORESET;
extern sys_printdef syspdef_NETUDPNOPORT;
extern sys_printdef syspdef_NETUDPINERR;
extern sys_printdef syspdef_NETUDPI;
extern sys_printdef syspdef_NETUDPO;
extern sys_printdef syspdef_NETNETWORK;
extern sys_printdef syspdef_NETIPI;
extern sys_printdef syspdef_NETIPO;
extern sys_printdef syspdef_NETIPFRW;
extern sys_printdef syspdef_NETIPDELIV;
extern sys_printdef syspdef_NETICMPIN;
extern sys_printdef syspdef_NETICMPOUT;
extern sys_printdef syspdef_NETNAME;
extern sys_printdef syspdef_NETPCKI;
extern sys_printdef syspdef_NETPCKO;
extern sys_printdef syspdef_NETSPEEDMAX;
extern sys_printdef syspdef_NETSPEEDIN;
extern sys_printdef syspdef_NETSPEEDOUT;
extern sys_printdef syspdef_NETCOLLIS;
extern sys_printdef syspdef_NETMULTICASTIN;
extern sys_printdef syspdef_NETRCVERR;
extern sys_printdef syspdef_NETSNDERR;
extern sys_printdef syspdef_NETRCVDROP;
extern sys_printdef syspdef_NETSNDDROP;
extern sys_printdef syspdef_NFMSERVER;
extern sys_printdef syspdef_NFMPATH;
extern sys_printdef syspdef_NFMTOTREAD;
extern sys_printdef syspdef_NFMTOTWRITE;
extern sys_printdef syspdef_NFMNREAD;
extern sys_printdef syspdef_NFMNWRITE;
extern sys_printdef syspdef_NFMDREAD;
extern sys_printdef syspdef_NFMDWRITE;
extern sys_printdef syspdef_NFMMREAD;
extern sys_printdef syspdef_NFMMWRITE;
extern sys_printdef syspdef_NFCRPCCNT;
extern sys_printdef syspdef_NFCRPCREAD;
extern sys_printdef syspdef_NFCRPCWRITE;
extern sys_printdef syspdef_NFCRPCRET;
extern sys_printdef syspdef_NFCRPCARF;
extern sys_printdef syspdef_NFSRPCCNT;
extern sys_printdef syspdef_NFSRPCREAD;
extern sys_printdef syspdef_NFSRPCWRITE;
extern sys_printdef syspdef_NFSBADFMT;
extern sys_printdef syspdef_NFSBADAUT;
extern sys_printdef syspdef_NFSBADCLN;
extern sys_printdef syspdef_NFSNETTCP;
extern sys_printdef syspdef_NFSNETUDP;
extern sys_printdef syspdef_NFSNRBYTES;
extern sys_printdef syspdef_NFSNWBYTES;
extern sys_printdef syspdef_NFSRCHITS;
extern sys_printdef syspdef_NFSRCMISS;
extern sys_printdef syspdef_NFSRCNOCA;
extern sys_printdef syspdef_BLANKBOX;
/*
** functions that print ???? for unavailable data
*/
char *procprt_NOTAVAIL_4(struct tstat *curstat, int avgval, int nsecs);
char *procprt_NOTAVAIL_5(struct tstat *curstat, int avgval, int nsecs);
char *procprt_NOTAVAIL_6(struct tstat *curstat, int avgval, int nsecs);
char *procprt_NOTAVAIL_7(struct tstat *curstat, int avgval, int nsecs);
extern proc_printdef *allprocpdefs[];
extern proc_printdef procprt_PID;
extern proc_printdef procprt_TID;
extern proc_printdef procprt_PPID;
extern proc_printdef procprt_SYSCPU;
extern proc_printdef procprt_USRCPU;
extern proc_printdef procprt_VGROW;
extern proc_printdef procprt_RGROW;
extern proc_printdef procprt_MINFLT;
extern proc_printdef procprt_MAJFLT;
extern proc_printdef procprt_VSTEXT;
extern proc_printdef procprt_VSIZE;
extern proc_printdef procprt_RSIZE;
extern proc_printdef procprt_PSIZE;
extern proc_printdef procprt_VSLIBS;
extern proc_printdef procprt_VDATA;
extern proc_printdef procprt_VSTACK;
extern proc_printdef procprt_SWAPSZ;
extern proc_printdef procprt_CMD;
extern proc_printdef procprt_RUID;
extern proc_printdef procprt_EUID;
extern proc_printdef procprt_SUID;
extern proc_printdef procprt_FSUID;
extern proc_printdef procprt_RGID;
extern proc_printdef procprt_EGID;
extern proc_printdef procprt_SGID;
extern proc_printdef procprt_FSGID;
extern proc_printdef procprt_CTID;
extern proc_printdef procprt_VPID;
extern proc_printdef procprt_CID;
extern proc_printdef procprt_STDATE;
extern proc_printdef procprt_STTIME;
extern proc_printdef procprt_ENDATE;
extern proc_printdef procprt_ENTIME;
extern proc_printdef procprt_THR;
extern proc_printdef procprt_TRUN;
extern proc_printdef procprt_TSLPI;
extern proc_printdef procprt_TSLPU;
extern proc_printdef procprt_POLI;
extern proc_printdef procprt_NICE;
extern proc_printdef procprt_PRI;
extern proc_printdef procprt_RTPR;
extern proc_printdef procprt_CURCPU;
extern proc_printdef procprt_ST;
extern proc_printdef procprt_EXC;
extern proc_printdef procprt_S;
extern proc_printdef procprt_COMMAND_LINE;
extern proc_printdef procprt_NPROCS;
extern proc_printdef procprt_RDDSK;
extern proc_printdef procprt_WRDSK;
extern proc_printdef procprt_CWRDSK;
extern proc_printdef procprt_WCANCEL;
extern proc_printdef procprt_TCPRCV;
extern proc_printdef procprt_TCPRASZ;
extern proc_printdef procprt_TCPSND;
extern proc_printdef procprt_TCPSASZ;
extern proc_printdef procprt_UDPRCV;
extern proc_printdef procprt_UDPRASZ;
extern proc_printdef procprt_UDPSND;
extern proc_printdef procprt_UDPSASZ;
extern proc_printdef procprt_RNET;
extern proc_printdef procprt_SNET;
extern proc_printdef procprt_BANDWI;
extern proc_printdef procprt_BANDWO;
extern proc_printdef procprt_SORTITEM;
//extern char *procprt_NRDDSK_ae(struct tstat *, int, int);
//extern char *procprt_NWRDSK_a(struct tstat *, int, int);
//extern char *procprt_NRDDSK_e(struct tstat *, int, int);
//extern char *procprt_NWRDSK_e(struct tstat *, int, int);
extern char *procprt_SNET_a(struct tstat *, int, int);
extern char *procprt_SNET_e(struct tstat *, int, int);
extern char *procprt_RNET_a(struct tstat *, int, int);
extern char *procprt_RNET_e(struct tstat *, int, int);
extern char *procprt_TCPSND_a(struct tstat *, int, int);
extern char *procprt_TCPRCV_a(struct tstat *, int, int);
extern char *procprt_UDPSND_a(struct tstat *, int, int);
extern char *procprt_UDPRCV_a(struct tstat *, int, int);
extern char *procprt_TCPSASZ_a(struct tstat *, int, int);
extern char *procprt_TCPRASZ_a(struct tstat *, int, int);
extern char *procprt_UDPSASZ_a(struct tstat *, int, int);
extern char *procprt_UDPRASZ_a(struct tstat *, int, int);
extern char *procprt_TCPSND_e(struct tstat *, int, int);
extern char *procprt_TCPRCV_e(struct tstat *, int, int);
extern char *procprt_UDPSND_e(struct tstat *, int, int);
extern char *procprt_UDPRCV_e(struct tstat *, int, int);
extern char *procprt_TCPSASZ_e(struct tstat *, int, int);
extern char *procprt_TCPRASZ_e(struct tstat *, int, int);
extern char *procprt_UDPSASZ_e(struct tstat *, int, int);
extern char *procprt_UDPRASZ_e(struct tstat *, int, int);