2
** This program is free software; you can redistribute it and/or modify it
3
** under the terms of the GNU General Public License as published by the
4
** Free Software Foundation; either version 2, or (at your option) any
7
** This program is distributed in the hope that it will be useful, but
8
** WITHOUT ANY WARRANTY; without even the implied warranty of
9
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
** See the GNU General Public License for more details.
12
** You should have received a copy of the GNU General Public License
13
** along with this program; if not, write to the Free Software
14
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
** structure which describes the raw file contents
19
** layout raw file: rawheader
22
** compressed system-level statistics | sample 1
23
** compressed process-level statistics /
26
** compressed system-level statistics | sample 2
27
** compressed process-level statistics /
31
#define ATOPLOGMAGIC (unsigned int) 0xfeedbeef
35
#include <sys/utsname.h>
37
typedef long long count_t;
39
/* These structures come from rawlog.c in ATop source */
44
unsigned short aversion; /* creator atop version with MSB */
45
unsigned short sstatlen; /* length of struct sstat */
46
unsigned short pstatlen; /* length of struct pstat */
47
unsigned short rawheadlen; /* length of struct rawheader */
48
unsigned short rawreclen; /* length of struct rawrecord */
49
unsigned short hertz; /* clock interrupts per second */
50
unsigned short sfuture[5]; /* future use */
51
struct utsname utsname; /* info about this system */
52
char cfuture[8]; /* future use */
54
unsigned int pagesize; /* size of memory page (bytes) */
55
int supportflags; /* used features */
56
int osrel; /* OS release number */
57
int osvers; /* OS version number */
58
int ossub; /* OS version subnumber */
59
int ifuture[6]; /* future use */
63
time_t curtime; /* current time (epoch) */
65
unsigned short flags; /* various flags */
66
unsigned short sfuture[3]; /* future use */
68
unsigned int scomplen; /* length of compressed sstat */
69
unsigned int pcomplen; /* length of compressed pstat's */
70
unsigned int interval; /* interval (number of seconds) */
71
unsigned int nlist; /* number of processes in list */
72
unsigned int npresent; /* total number of processes */
73
unsigned int nexit; /* number of exited processes */
74
unsigned int nzombie; /* number of zombie processes */
75
unsigned int ifuture[6]; /* future use */
79
** structure containing only relevant process-info extracted
80
** from kernel's process-administration
83
/* GENERAL PROCESS INFO */
85
int pid; /* process identification */
86
int ruid; /* real user identification */
87
int rgid; /* real group identification */
88
int ppid; /* parent process identification*/
89
int nthr; /* number of threads in tgroup */
90
char name[PNAMLEN+1];/* process name string */
91
char state; /* process state ('E' = exited) */
92
int excode; /* process exit status */
93
time_t btime; /* process start time (epoch) */
94
char cmdline[CMDLEN+1];/* command-line string */
95
int nthrslpi; /* # threads in state 'S' */
96
int nthrslpu; /* # threads in state 'D' */
97
int nthrrun; /* # threads in state 'R' */
98
int ifuture[1]; /* reserved */
103
count_t utime; /* time user text (ticks) */
104
count_t stime; /* time system text (ticks) */
105
int nice; /* nice value */
106
int prio; /* priority */
107
int rtprio; /* realtime priority */
108
int policy; /* scheduling policy */
109
int curcpu; /* current processor */
110
int sleepavg; /* sleep average percentage */
111
int ifuture[4]; /* reserved for future use */
112
count_t cfuture[4]; /* reserved for future use */
115
/* DISK STATISTICS */
117
count_t rio; /* number of read requests */
118
count_t rsz; /* cumulative # sectors read */
119
count_t wio; /* number of write requests */
120
count_t wsz; /* cumulative # sectors written */
121
count_t cwsz; /* cumulative # written sectors */
122
/* being cancelled */
123
count_t cfuture[4]; /* reserved for future use */
126
/* MEMORY STATISTICS */
128
count_t minflt; /* number of page-reclaims */
129
count_t majflt; /* number of page-faults */
130
count_t shtext; /* text memory (Kb) */
131
count_t vmem; /* virtual memory (Kb) */
132
count_t rmem; /* resident memory (Kb) */
133
count_t vgrow; /* virtual growth (Kb) */
134
count_t rgrow; /* resident growth (Kb) */
135
count_t cfuture[4]; /* reserved for future use */
138
/* NETWORK STATISTICS */
140
count_t tcpsnd; /* number of TCP-packets sent */
141
count_t tcpssz; /* cumulative size packets sent */
142
count_t tcprcv; /* number of TCP-packets recved */
143
count_t tcprsz; /* cumulative size packets rcvd */
144
count_t udpsnd; /* number of UDP-packets sent */
145
count_t udpssz; /* cumulative size packets sent */
146
count_t udprcv; /* number of UDP-packets recved */
147
count_t udprsz; /* cumulative size packets sent */
148
count_t rawsnd; /* number of raw packets sent */
149
count_t rawrcv; /* number of raw packets recved */
150
count_t cfuture[4]; /* reserved for future use */
156
PInfo *phnext; /* next process in hash chain */
157
PInfo *prnext; /* next process in residue chain */
158
PInfo *prprev; /* prev process in residue chain */
159
PStat pstat; /* per-process statistics */