~ubuntu-branches/ubuntu/oneiric/apachetop/oneiric

« back to all changes in this revision

Viewing changes to .pc/01-conglomeration.patch/src/apachetop.h

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Sammicheli
  • Date: 2011-05-02 13:22:26 UTC
  • mfrom: (8.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110502132226-fj9j7hhrl33u4vcn
Tags: 0.12.6-13ubuntu1
* Merge from debian unstable. (LP: #776597) Remaining changes: 
  - debian/patches/02-maxpathlen.patch: Update and autoreconf -f -i,
    fixes FTBFS 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _APACHETOP_H_
 
2
#define _APACHETOP_H_
 
3
 
 
4
#if HAVE_CONFIG_H
 
5
# include "config.h"
 
6
#endif
 
7
 
 
8
#include <stdio.h>
 
9
#include <errno.h>
 
10
#include <ctype.h>
 
11
#include <string.h>
 
12
 
 
13
#if HAVE_STRINGS_H
 
14
# include <strings.h>
 
15
#endif
 
16
 
 
17
#include <fcntl.h>
 
18
 
 
19
#include <signal.h>
 
20
 
 
21
#include <stdlib.h>
 
22
#include <stdarg.h>
 
23
#include <unistd.h>
 
24
#include <sys/types.h>
 
25
#include <sys/stat.h>
 
26
 
 
27
#if TIME_WITH_SYS_TIME
 
28
# include <sys/time.h>
 
29
# include <time.h>
 
30
#else
 
31
# if HAVE_SYS_TIME_H
 
32
#  include <sys/time.h>
 
33
# else
 
34
#  include <time.h>
 
35
# endif
 
36
#endif
 
37
 
 
38
#if HAVE_SYS_SOCKET_H
 
39
# include <sys/socket.h>
 
40
#endif
 
41
 
 
42
#if HAVE_NETINET_IN_H
 
43
# include <netinet/in.h>
 
44
#endif
 
45
 
 
46
#if HAVE_ARPA_INET_H
 
47
# include <arpa/inet.h>
 
48
#endif
 
49
 
 
50
#if HAVE_NETDB_H
 
51
# include <netdb.h>
 
52
#endif
 
53
 
 
54
#if HAVE_PCRE_H
 
55
# include <pcre.h>
 
56
# include "pcre_cpp_wrapper.h"
 
57
#endif
 
58
 
 
59
#include <curses.h>
 
60
 
 
61
#include <readline/readline.h>
 
62
#include <readline/history.h>
 
63
 
 
64
/* Use kqueue in preference to anything else.
 
65
 *  If we don't have that, try FAM
 
66
 *   If we don't have FAM, fall back to stat()
 
67
*/
 
68
#define USING_KQUEUE 1
 
69
#define USING_FAM    2
 
70
#define USING_STAT   3
 
71
#if HAVE_KQUEUE
 
72
# include <sys/event.h>
 
73
# define POLLING_METHOD USING_KQUEUE
 
74
#elif HAVE_FAM_H
 
75
# include <fam.h>
 
76
# define POLLING_METHOD USING_FAM
 
77
#endif
 
78
 
 
79
/* stat() fallback */
 
80
#ifndef POLLING_METHOD
 
81
# define POLLING_METHOD USING_STAT
 
82
#endif
 
83
 
 
84
#if HAVE_ADNS_H
 
85
# include <adns.h>
 
86
#endif
 
87
 
 
88
 
 
89
#define getMIN(a,b) (a < b ? a : b)
 
90
#define getMAX(a,b) (a > b ? a : b)
 
91
 
 
92
#ifndef MAXPATHLEN
 
93
# define MAXPATHLEN 128
 
94
#endif
 
95
 
 
96
/* upon startup, each input file is put into an element of this array,
 
97
 * starting at 0. The struct under this maps the current fd into this array
 
98
 * so we can find it without iterating.
 
99
*/
 
100
struct input {
 
101
        char *filename;
 
102
        int fd;
 
103
        ino_t inode;
 
104
        short type; /* types defined in log.h */
 
105
        time_t lastreq;
 
106
 
 
107
        /* if open == false, then ApacheTop will periodically try to re-open
 
108
         * this input file. */
 
109
        bool open; /* is the file open or not? */
 
110
 
 
111
#if (POLLING_METHOD == USING_FAM)
 
112
        FAMRequest famreq;
 
113
#endif
 
114
};
 
115
 
 
116
#include "filters.h"
 
117
 
 
118
struct config {
 
119
        #define SORT_REQCOUNT 1
 
120
        #define SORT_REQPERSEC 2
 
121
        #define SORT_BYTECOUNT 3
 
122
        #define SORT_BYTESPERSEC 4
 
123
        #define SORT_2XX 12 /* see display.cc around line 911 (shellsort)  */
 
124
        #define SORT_3XX 13 /* for the consequences of changing these.     */
 
125
        #define SORT_4XX 14 /* Logic there relies on them being            */
 
126
        #define SORT_5XX 15 /* (retcode/100)+SORTTYPE_OFFSET_HACK          */
 
127
        #define SORTTYPE_OFFSET_HACK 10
 
128
        short sort, retcodes_sort;
 
129
        short refresh_delay;
 
130
 
 
131
        short do_resolving;
 
132
 
 
133
        short selected_item_screen; /* screen position our marker is at */
 
134
        unsigned int selected_item_pos; /* which url/ip/refpos it relates to */
 
135
        short selected_item_mode; /* is it url/ip/ref pos? */
 
136
        unsigned int selected_item_hash;
 
137
 
 
138
        short current_display_size; /* how many lines we're displaying */
 
139
 
 
140
        short input_count;
 
141
 
 
142
        #define TIMED_CIRCLE 'T'
 
143
        #define HITS_CIRCLE  'H'
 
144
        int circle_mode;
 
145
        int circle_size;
 
146
 
 
147
        /* these defines are used in cf.filter too */
 
148
        #define DISPLAY_URLS   1
 
149
        #define DISPLAY_HOSTS  2
 
150
        #define DISPLAY_REFS   3
 
151
        #define DISPLAY_FILES  4
 
152
        #define DISPLAY_DETAIL 9
 
153
        short display_mode;
 
154
 
 
155
        #define NUMBERS_HITS_BYTES  1
 
156
        #define NUMBERS_RETCODES    2
 
157
        short numbers_mode;
 
158
 
 
159
        /* when in DISPLAY_DETAIL mode, display_mode is copied in here */
 
160
        short display_mode_detail;
 
161
        /* what would we like to display in DISPLAY_DETAIL modes? */
 
162
        bool detail_display_hosts, detail_display_refs, detail_display_urls;
 
163
 
 
164
        bool display_paused;
 
165
        bool do_immed_display; /* signals a screen update is req'd */
 
166
 
 
167
        /* filters */
 
168
        Filter *urlfilter, *hostfilter, *reffilter;
 
169
 
 
170
        /* url munging */
 
171
        bool keep_querystring;
 
172
        bool lowercase_urls;
 
173
        unsigned short keep_segments;
 
174
        bool preserve_ref_protocol;
 
175
 
 
176
        bool debug;
 
177
 
 
178
        bool exit; /* true when we want to finish */
 
179
 
 
180
        /* keypress submenu */
 
181
        #define SUBMENU_NONE          0
 
182
 
 
183
        #define SUBMENU_SORT_HB       1
 
184
        #define SUBMENU_SORT_RC       2
 
185
 
 
186
        #define SUBMENU_DISP          4
 
187
 
 
188
        #define SUBMENU_FILT          5
 
189
        #define SUBMENU_FILT_ADD      6
 
190
        #define SUBMENU_FILT_SHOW     7
 
191
 
 
192
        #define SUBMENU_HELP          9
 
193
        unsigned short in_submenu;
 
194
        bool in_submenu_stay; /* stay in submenu till keypress? */
 
195
        time_t in_submenu_time;
 
196
 
 
197
};
 
198
 
 
199
struct hitinfo {
 
200
        double bytecount;
 
201
        double reqcount;
 
202
        time_t first, last;
 
203
 
 
204
        /* for stats worked out in display.cc */
 
205
        float rps, bps;
 
206
};
 
207
 
 
208
struct gstat {
 
209
        time_t start; /* when did we start */
 
210
 
 
211
        /* space for 1xx-5xx return codes */
 
212
        struct hitinfo r_codes[6];
 
213
 
 
214
        /* space for counting global hits and bytes per sec */
 
215
        struct hitinfo alltime;
 
216
};
 
217
 
 
218
//#include "opt.h"
 
219
#include "ohtbl.h"
 
220
 
 
221
#if HAVE_ADNS_H
 
222
# include "resolver.h"
 
223
#endif
 
224
 
 
225
#include "map.h"
 
226
#include "circle.h"
 
227
#include "hits_circle.h"
 
228
#include "timed_circle.h"
 
229
#include "display.h"
 
230
#include "log.h"
 
231
#include "queue.h"
 
232
 
 
233
 
 
234
#define JAN 281
 
235
#define FEB 269
 
236
#define MAR 288
 
237
#define APR 291
 
238
#define MAY 295
 
239
#define JUN 301
 
240
#define JUL 299
 
241
#define AUG 285
 
242
#define SEP 296
 
243
#define OCT 294
 
244
#define NOV 307
 
245
#define DEC 268
 
246
 
 
247
#define DEBUG_OUTPUT "/tmp/atop.debug"
 
248
 
 
249
/* this can be overridden from config.h via ./configure --with-logfile .. */
 
250
#ifndef DEFAULT_LOGFILE
 
251
# define DEFAULT_LOGFILE "/var/httpd/apache_log"
 
252
#endif
 
253
#define DEFAULT_CIRCLE_SIZE 30
 
254
#define DEFAULT_CIRCLE_MODE TIMED_CIRCLE
 
255
#define DEFAULT_SORT SORT_REQCOUNT
 
256
#define DEFAULT_RETCODES_SORT SORT_2XX
 
257
#define DEFAULT_REFRESH_DELAY 5
 
258
#define DEFAULT_DISPLAY_MODE DISPLAY_URLS
 
259
#define DEFAULT_NUMBERS_MODE NUMBERS_HITS_BYTES
 
260
 
 
261
/* if the layout of the display changes, these need updating */
 
262
#define COLS_RESERVED 25
 
263
#define LINES_RESERVED 7
 
264
 
 
265
#define MAX_INPUT_FILES 50
 
266
 
 
267
int recordstats(struct logbits l);
 
268
 
 
269
int read_key(int ch);
 
270
 
 
271
#define SEEK_TO_END true
 
272
#define NO_SEEK_TO_END false
 
273
int new_file(char *filename, bool do_seek_to_end);
 
274
 
 
275
void usage(void);
 
276
int dprintf(const char *fmt, ...);
 
277
 
 
278
static void catchsig(int s);
 
279
static void catchwinch(int s);
 
280
 
 
281
#endif