File indexing completed on 2024-04-28 16:49:51
0001 /* 0002 SPDX-FileCopyrightText: 2010 John Tapsell <john.tapsell@kdemail.net> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 /* 0006 ** structure which describes the raw file contents 0007 ** 0008 ** layout raw file: rawheader 0009 ** 0010 ** rawrecord \ 0011 ** compressed system-level statistics | sample 1 0012 ** compressed process-level statistics / 0013 ** 0014 ** rawrecord \ 0015 ** compressed system-level statistics | sample 2 0016 ** compressed process-level statistics / 0017 ** 0018 ** etcetera ..... 0019 */ 0020 #ifndef KSYSGUARD_ATOP_P_H 0021 #define KSYSGUARD_ATOP_P_H 0022 0023 #define ATOPLOGMAGIC (unsigned int)0xfeedbeef 0024 #define PNAMLEN 15 0025 #define CMDLEN 68 0026 0027 #include <sys/utsname.h> 0028 #include <time.h> 0029 typedef long long count_t; 0030 0031 /* These structures come from rawlog.c in ATop source */ 0032 0033 struct RawHeader { 0034 unsigned int magic; 0035 0036 unsigned short aversion; /* creator atop version with MSB */ 0037 unsigned short sstatlen; /* length of struct sstat */ 0038 unsigned short pstatlen; /* length of struct pstat */ 0039 unsigned short rawheadlen; /* length of struct rawheader */ 0040 unsigned short rawreclen; /* length of struct rawrecord */ 0041 unsigned short hertz; /* clock interrupts per second */ 0042 unsigned short sfuture[5]; /* future use */ 0043 struct utsname utsname; /* info about this system */ 0044 char cfuture[8]; /* future use */ 0045 0046 unsigned int pagesize; /* size of memory page (bytes) */ 0047 int supportflags; /* used features */ 0048 int osrel; /* OS release number */ 0049 int osvers; /* OS version number */ 0050 int ossub; /* OS version subnumber */ 0051 int ifuture[6]; /* future use */ 0052 }; 0053 0054 struct RawRecord { 0055 time_t curtime; /* current time (epoch) */ 0056 0057 unsigned short flags; /* various flags */ 0058 unsigned short sfuture[3]; /* future use */ 0059 0060 unsigned int scomplen; /* length of compressed sstat */ 0061 unsigned int pcomplen; /* length of compressed pstat's */ 0062 unsigned int interval; /* interval (number of seconds) */ 0063 unsigned int nlist; /* number of processes in list */ 0064 unsigned int npresent; /* total number of processes */ 0065 unsigned int nexit; /* number of exited processes */ 0066 unsigned int nzombie; /* number of zombie processes */ 0067 unsigned int ifuture[6]; /* future use */ 0068 }; 0069 0070 /* 0071 ** structure containing only relevant process-info extracted 0072 ** from kernel's process-administration 0073 */ 0074 struct PStat { 0075 /* GENERAL PROCESS INFO */ 0076 struct gen { 0077 int pid; /* process identification */ 0078 int ruid; /* real user identification */ 0079 int rgid; /* real group identification */ 0080 int ppid; /* parent process identification*/ 0081 int nthr; /* number of threads in tgroup */ 0082 char name[PNAMLEN + 1]; /* process name string */ 0083 char state; /* process state ('E' = exited) */ 0084 int excode; /* process exit status */ 0085 time_t btime; /* process start time (epoch) */ 0086 char cmdline[CMDLEN + 1]; /* command-line string */ 0087 int nthrslpi; /* # threads in state 'S' */ 0088 int nthrslpu; /* # threads in state 'D' */ 0089 int nthrrun; /* # threads in state 'R' */ 0090 int ifuture[1]; /* reserved */ 0091 } gen; 0092 0093 /* CPU STATISTICS */ 0094 struct cpu { 0095 count_t utime; /* time user text (ticks) */ 0096 count_t stime; /* time system text (ticks) */ 0097 int nice; /* nice value */ 0098 int prio; /* priority */ 0099 int rtprio; /* realtime priority */ 0100 int policy; /* scheduling policy */ 0101 int curcpu; /* current processor */ 0102 int sleepavg; /* sleep average percentage */ 0103 int ifuture[4]; /* reserved for future use */ 0104 count_t cfuture[4]; /* reserved for future use */ 0105 } cpu; 0106 0107 /* DISK STATISTICS */ 0108 struct dsk { 0109 count_t rio; /* number of read requests */ 0110 count_t rsz; /* cumulative # sectors read */ 0111 count_t wio; /* number of write requests */ 0112 count_t wsz; /* cumulative # sectors written */ 0113 count_t cwsz; /* cumulative # written sectors */ 0114 /* being cancelled */ 0115 count_t cfuture[4]; /* reserved for future use */ 0116 } dsk; 0117 0118 /* MEMORY STATISTICS */ 0119 struct mem { 0120 count_t minflt; /* number of page-reclaims */ 0121 count_t majflt; /* number of page-faults */ 0122 count_t shtext; /* text memory (Kb) */ 0123 count_t vmem; /* virtual memory (Kb) */ 0124 count_t rmem; /* resident memory (Kb) */ 0125 count_t vgrow; /* virtual growth (Kb) */ 0126 count_t rgrow; /* resident growth (Kb) */ 0127 count_t cfuture[4]; /* reserved for future use */ 0128 } mem; 0129 0130 /* NETWORK STATISTICS */ 0131 struct net { 0132 count_t tcpsnd; /* number of TCP-packets sent */ 0133 count_t tcpssz; /* cumulative size packets sent */ 0134 count_t tcprcv; /* number of TCP-packets received */ 0135 count_t tcprsz; /* cumulative size packets rcvd */ 0136 count_t udpsnd; /* number of UDP-packets sent */ 0137 count_t udpssz; /* cumulative size packets sent */ 0138 count_t udprcv; /* number of UDP-packets received */ 0139 count_t udprsz; /* cumulative size packets sent */ 0140 count_t rawsnd; /* number of raw packets sent */ 0141 count_t rawrcv; /* number of raw packets received */ 0142 count_t cfuture[4]; /* reserved for future use */ 0143 } net; 0144 }; 0145 0146 struct PInfo; 0147 struct PInfo { 0148 PInfo *phnext; /* next process in hash chain */ 0149 PInfo *prnext; /* next process in residue chain */ 0150 PInfo *prprev; /* prev process in residue chain */ 0151 PStat pstat; /* per-process statistics */ 0152 }; 0153 0154 #endif // KSYSGUARD_ATOP_P_H