~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/ksysguard/processcore/atop_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
5
** later version.
 
6
**
 
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.
 
11
**
 
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
 
15
*/
 
16
/*
 
17
** structure which describes the raw file contents
 
18
**
 
19
** layout raw file:    rawheader
 
20
**
 
21
**                     rawrecord                           \
 
22
**                     compressed system-level statistics   | sample 1
 
23
**                     compressed process-level statistics /
 
24
**
 
25
**                     rawrecord                           \
 
26
**                     compressed system-level statistics   | sample 2
 
27
**                     compressed process-level statistics /
 
28
**
 
29
** etcetera .....
 
30
*/
 
31
#define ATOPLOGMAGIC     (unsigned int) 0xfeedbeef
 
32
#define PNAMLEN     15
 
33
#define CMDLEN      68
 
34
 
 
35
#include <sys/utsname.h>
 
36
#include <time.h>
 
37
typedef long long   count_t;
 
38
 
 
39
/* These structures come from rawlog.c in ATop source */
 
40
 
 
41
struct RawHeader {
 
42
    unsigned int    magic;
 
43
 
 
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                    */
 
53
 
 
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                    */
 
60
};
 
61
 
 
62
struct RawRecord {
 
63
    time_t      curtime;    /* current time (epoch)         */
 
64
 
 
65
    unsigned short  flags;      /* various flags                */
 
66
    unsigned short  sfuture[3]; /* future use                   */
 
67
 
 
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                   */
 
76
};
 
77
 
 
78
/* 
 
79
** structure containing only relevant process-info extracted 
 
80
** from kernel's process-administration
 
81
*/
 
82
struct PStat {
 
83
    /* GENERAL PROCESS INFO                     */
 
84
    struct gen {
 
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                     */
 
99
    } gen;
 
100
 
 
101
    /* CPU STATISTICS                       */
 
102
    struct cpu {
 
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  */
 
113
    } cpu;
 
114
 
 
115
    /* DISK STATISTICS                      */
 
116
    struct dsk {
 
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  */
 
124
    } dsk;
 
125
 
 
126
    /* MEMORY STATISTICS                        */
 
127
    struct mem {
 
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  */
 
136
    } mem;
 
137
 
 
138
    /* NETWORK STATISTICS                       */
 
139
    struct net {
 
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  */
 
151
    } net;
 
152
};
 
153
 
 
154
struct PInfo;
 
155
struct PInfo {
 
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        */
 
160
};
 
161
 
 
162