-
Notifications
You must be signed in to change notification settings - Fork 113
/
photosyst.h
480 lines (403 loc) · 15.5 KB
/
photosyst.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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
/*
** 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 system-level counters maintained.
** ================================================================
** 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 __PHOTOSYST__
#define __PHOTOSYST__
#include "netstats.h"
#define MAXCPU 2048
#define MAXDSK 1024
#define MAXNUMA 1024
#define MAXLVM 2048
#define MAXMDD 256
#define MAXINTF 128
#define MAXCONTAINER 128
#define MAXNFSMOUNT 64
#define MAXIBPORT 32
#define MAXGPU 32
#define MAXGPUBUS 12
#define MAXGPUTYPE 12
#define MAXLLC 256
#define MAXDKNAM 32
#define MAXIBNAME 12
/************************************************************************/
struct memstat {
count_t physmem; // number of physical pages
count_t freemem; // number of free pages
count_t buffermem; // number of buffer pages
count_t slabmem; // number of slab pages
count_t cachemem; // number of cache pages
count_t cachedrt; // number of cache pages (dirty)
count_t totswap; // number of pages in swap
count_t freeswap; // number of free swap pages
count_t pgscans; // number of page scans
count_t pgsteal; // number of page steals
count_t allocstall; // try to free pages forced
count_t swouts; // number of pages swapped out
count_t swins; // number of pages swapped in
count_t tcpsock; // number of pages allocated by TCP sockets
count_t udpsock; // number of pages allocated by UDP sockets
count_t commitlim; // commit limit in pages
count_t committed; // number of reserved pages
count_t shmem; // tot shmem incl. tmpfs (pages)
count_t shmrss; // resident shared memory (pages)
count_t shmswp; // swapped shared memory (pages)
count_t slabreclaim; // reclaimable slab (pages)
count_t stothugepage; // total huge pages (huge pages) - small
count_t sfreehugepage; // free huge pages (huge pages) - small
count_t shugepagesz; // huge page size (bytes) - small
count_t vmwballoon; // vmware claimed balloon pages
count_t zfsarcsize; // zfsonlinux ARC size (pages)
count_t swapcached; // swap cache (pages)
count_t ksmsharing; // saved i.e. deduped memory (pages)
count_t ksmshared; // current size shared pages (pages)
count_t zswapped; // zswap stored pages decompressed (pages)
count_t zswap; // zswap current pool size compressed (pages)
count_t oomkills; // number of oom killings
count_t compactstall; // counter for process stalls
count_t pgmigrate; // counter for migrated successfully (pages)
count_t numamigrate; // counter for numa migrated (pages)
count_t pgouts; // total number of pages written to block device
count_t pgins; // total number of pages read from block device
count_t pagetables; // page tables of processes (pages)
count_t zswouts; // number of pages swapped out to zswap
count_t zswins; // number of pages swapped in from zswap
count_t ltothugepage; // total huge pages (huge pages) - large
count_t lfreehugepage; // free huge pages (huge pages) - large
count_t lhugepagesz; // huge page size (bytes) - large
count_t availablemem; // available memory (pages)
count_t anonhugepage; // anonymous transparent huge pages
// (in units of 'normal' pages)
count_t cfuture[5]; // reserved for future use
};
/************************************************************************/
struct mempernuma {
int numanr;
float frag; // fragmentation level for this numa
count_t totmem; // number of physical pages for this numa
count_t freemem; // number of free pages for this numa
count_t filepage; // number of file pages for this numa
count_t dirtymem; // number of cache pages (dirty) for this numa
count_t slabmem; // number of slab pages for this numa
count_t slabreclaim; // reclaimable slab (pages) for this numa
count_t active; // number of pages used more recently for this numa
count_t inactive; // number of pages less recently used for this numa
count_t shmem; // tot shmem incl. tmpfs (pages) for this numa
count_t tothp; // total huge pages (huge pages) for this numa
count_t freehp; // total free pages (huge pages) for this numa
count_t cfuture[2]; // reserved for future use
};
struct memnuma {
count_t nrnuma; /* the counts of numa */
struct mempernuma numa[MAXNUMA];
};
struct cpupernuma {
int numanr;
count_t nrcpu; // number of cpu's
count_t stime; // accumulate system time in clock ticks for per numa
count_t utime; // accumulate user time in clock ticks for per numa
count_t ntime; // accumulate nice time in clock ticks for per numa
count_t itime; // accumulate idle time in clock ticks for per numa
count_t wtime; // accumulate iowait time in clock ticks for per numa
count_t Itime; // accumulate irq time in clock ticks for per numa
count_t Stime; // accumulate softirq time in clock ticks for per numa
count_t steal; // accumulate steal time in clock ticks for per numa
count_t guest; // accumulate guest time in clock ticks for per numa
count_t cfuture[2]; // reserved for future use
};
struct cpunuma {
count_t nrnuma; /* the counts of numa */
struct cpupernuma numa[MAXNUMA];
};
/************************************************************************/
struct netstat {
struct ipv4_stats ipv4;
struct icmpv4_stats icmpv4;
struct udpv4_stats udpv4;
struct ipv6_stats ipv6;
struct icmpv6_stats icmpv6;
struct udpv6_stats udpv6;
struct tcp_stats tcp;
};
/************************************************************************/
struct freqcnt {
count_t maxfreq;/* frequency in MHz */
count_t cnt; /* number of clock ticks times state */
count_t ticks; /* number of total clock ticks */
/* if zero, cnt is actual freq */
};
struct percpu {
int cpunr;
count_t stime; /* system time in clock ticks */
count_t utime; /* user time in clock ticks */
count_t ntime; /* nice time in clock ticks */
count_t itime; /* idle time in clock ticks */
count_t wtime; /* iowait time in clock ticks */
count_t Itime; /* irq time in clock ticks */
count_t Stime; /* softirq time in clock ticks */
count_t steal; /* steal time in clock ticks */
count_t guest; /* guest time in clock ticks */
struct freqcnt freqcnt;/* frequency scaling info */
count_t instr; /* CPU instructions */
count_t cycle; /* CPU cycles */
count_t cfuture[6]; /* reserved for future use */
};
struct cpustat {
count_t nrcpu; /* number of cpu's */
count_t devint; /* number of device interrupts */
count_t csw; /* number of context switches */
count_t nprocs; /* number of processes started */
float lavg1; /* load average last minute */
float lavg5; /* load average last 5 minutes */
float lavg15; /* load average last 15 minutes */
count_t cfuture[4]; /* reserved for future use */
struct percpu all;
struct percpu cpu[MAXCPU];
};
/************************************************************************/
struct perdsk {
char name[MAXDKNAM]; /* empty string for last */
count_t nread; /* number of read transfers */
count_t nrsect; /* number of sectors read */
count_t nwrite; /* number of write transfers */
count_t nwsect; /* number of sectors written */
count_t io_ms; /* number of millisecs spent for I/O */
count_t avque; /* average queue length */
count_t ndisc; /* number of discards (-1 = unavailable)*/
count_t ndsect; /* number of sectors discarded */
count_t inflight; /* number of inflight I/O */
count_t cfuture[3]; /* reserved for future use */
};
struct dskstat {
int ndsk; /* number of physical disks */
int nmdd; /* number of md volumes */
int nlvm; /* number of logical volumes */
struct perdsk dsk[MAXDSK];
struct perdsk mdd[MAXMDD];
struct perdsk lvm[MAXLVM];
};
/************************************************************************/
struct perintf {
char name[16]; /* empty string for last */
count_t rbyte; /* number of read bytes */
count_t rpack; /* number of read packets */
count_t rerrs; /* receive errors */
count_t rdrop; /* receive drops */
count_t rfifo; /* receive fifo */
count_t rframe; /* receive framing errors */
count_t rcompr; /* receive compressed */
count_t rmultic;/* receive multicast */
count_t rfuture[4]; /* reserved for future use */
count_t sbyte; /* number of written bytes */
count_t spack; /* number of written packets */
count_t serrs; /* transmit errors */
count_t sdrop; /* transmit drops */
count_t sfifo; /* transmit fifo */
count_t scollis;/* collisions */
count_t scarrier;/* transmit carrier */
count_t scompr; /* transmit compressed */
count_t sfuture[4]; /* reserved for future use */
char type; /* interface type ('e'/'w'/'v'/'?') */
long speed; /* interface speed in megabits/second */
long speedp; /* previous interface speed */
char duplex; /* full duplex (boolean) */
count_t cfuture[4]; /* reserved for future use */
};
struct intfstat {
int nrintf;
struct perintf intf[MAXINTF];
};
/************************************************************************/
struct pernfsmount {
char mountdev[128]; /* mountdevice */
count_t age; /* number of seconds mounted */
count_t bytesread; /* via normal reads */
count_t byteswrite; /* via normal writes */
count_t bytesdread; /* via direct reads */
count_t bytesdwrite; /* via direct writes */
count_t bytestotread; /* via reads */
count_t bytestotwrite; /* via writes */
count_t pagesmread; /* via mmap reads */
count_t pagesmwrite; /* via mmap writes */
count_t future[8];
};
struct nfsstat {
struct {
count_t netcnt;
count_t netudpcnt;
count_t nettcpcnt;
count_t nettcpcon;
count_t rpccnt;
count_t rpcbadfmt;
count_t rpcbadaut;
count_t rpcbadcln;
count_t rpcread;
count_t rpcwrite;
count_t rchits; /* repcache hits */
count_t rcmiss; /* repcache misses */
count_t rcnoca; /* uncached requests */
count_t nrbytes; /* read bytes */
count_t nwbytes; /* written bytes */
count_t future[8];
} server;
struct {
count_t rpccnt;
count_t rpcretrans;
count_t rpcautrefresh;
count_t rpcread;
count_t rpcwrite;
count_t future[8];
} client;
struct {
int nrmounts;
struct pernfsmount nfsmnt[MAXNFSMOUNT];
} nfsmounts;
};
/************************************************************************/
struct psi {
float avg10; // average pressure last 10 seconds
float avg60; // average pressure last 60 seconds
float avg300; // average pressure last 300 seconds
count_t total; // total number of milliseconds
};
struct pressure {
char present; /* pressure stats supported? */
char future[3];
struct psi cpusome; /* pressure stall info 'some' */
struct psi memsome; /* pressure stall info 'some' */
struct psi memfull; /* pressure stall info 'full' */
struct psi iosome; /* pressure stall info 'some' */
struct psi iofull; /* pressure stall info 'full' */
};
/************************************************************************/
struct percontainer {
unsigned long ctid; /* container id */
unsigned long numproc; /* number of processes */
count_t system; /* */
count_t user; /* */
count_t nice; /* */
count_t uptime; /* */
count_t physpages; /* */
};
struct contstat {
int nrcontainer;
struct percontainer cont[MAXCONTAINER];
};
/************************************************************************/
/*
** experimental stuff for access to local HTTP daemons
*/
#define HTTPREQ "GET /server-status?auto HTTP/1.1\nHost: localhost\n\n"
struct wwwstat {
count_t accesses; /* total number of HTTP-requests */
count_t totkbytes; /* total kbytes transfer for HTTP-req */
count_t uptime; /* number of seconds since startup */
int bworkers; /* number of busy httpd-daemons */
int iworkers; /* number of idle httpd-daemons */
};
#if HTTPSTATS
int getwwwstat(unsigned short, struct wwwstat *);
#endif
/************************************************************************/
struct pergpu {
char taskstats; // GPU task statistics supported?
unsigned char nrprocs; // number of processes using GPU
char type[MAXGPUTYPE+1]; // GPU type
char busid[MAXGPUBUS+1]; // GPU bus identification
int gpunr; // GPU number
int gpupercnow; // processor percentage last second
// -1 if not supported
int mempercnow; // memory percentage last second
// -1 if not supported
count_t memtotnow; // total memory in KiB
count_t memusenow; // used memory in KiB
count_t samples; // number of samples
count_t gpuperccum; // cumulative processor busy percentage
// -1 if not supported
count_t memperccum; // cumulative memory percentage
// -1 if not supported
count_t memusecum; // cumulative used memory in KiB
};
struct gpustat {
int nrgpus; // total number of GPUs
struct pergpu gpu[MAXGPU];
};
/************************************************************************/
struct perifb {
char ibname[MAXIBNAME]; // InfiniBand controller
short portnr; // InfiniBand controller port
short lanes; // number of lanes (traffic factor)
count_t rate; // transfer rate in megabits/sec
count_t rcvb; // bytes received
count_t sndb; // bytes transmitted
count_t rcvp; // packets received
count_t sndp; // packets transmitted
count_t cfuture[4]; // reserved for future use
};
struct ifbstat {
int nrports; // total number of IB ports
struct perifb ifb[MAXIBPORT];
};
/************************************************************************/
struct perllc {
unsigned char id;
float occupancy;
count_t mbm_local;
count_t mbm_total;
};
struct llcstat {
int nrllcs; // total number of LLC
struct perllc perllc[MAXLLC];
};
/************************************************************************/
struct sstat {
struct cpustat cpu;
struct memstat mem;
struct netstat net;
struct intfstat intf;
struct memnuma memnuma;
struct cpunuma cpunuma;
struct dskstat dsk;
struct nfsstat nfs;
struct contstat cfs;
struct pressure psi;
struct gpustat gpu;
struct ifbstat ifb;
struct llcstat llc;
struct wwwstat www;
};
/*
** prototypes
*/
void photosyst (struct sstat *);
void deviatsyst(struct sstat *, struct sstat *, struct sstat *, long);
void totalsyst (char, struct sstat *, struct sstat *);
void do_perfevents(char *, char *);
int isdisk_major(unsigned int);
/*
** return value of isdisk_...()
*/
#define NONTYPE 0
#define DSKTYPE 1
#define MDDTYPE 2
#define LVMTYPE 3
#endif