[MINOR] stats: add global event ID and count

This counter will help quickly spot whether there are new errors or not.
It is also assigned to each capture so that a script can keep trace of
which capture was taken when.
This commit is contained in:
Willy Tarreau 2010-12-12 14:00:34 +01:00
parent e1582eb7f6
commit 10479e4bac
4 changed files with 21 additions and 4 deletions

View File

@ -161,6 +161,7 @@ struct error_snapshot {
unsigned int len; /* original length of the last invalid request/response */
unsigned int pos; /* position of the first invalid character */
unsigned int sid; /* ID of the faulty session */
unsigned int ev_id; /* event number (counter incremented for each capture) */
unsigned int state; /* message state before the error (when saved) */
unsigned int flags; /* buffer flags */
struct server *srv; /* server associated with the error (or NULL) */
@ -363,6 +364,7 @@ struct redirect_rule {
extern struct proxy *proxy;
extern struct eb_root used_proxy_id; /* list of proxy IDs in use */
extern unsigned int error_snapshot_id; /* global ID assigned to each error then incremented */
#endif /* _TYPES_PROXY_H */

View File

@ -3426,6 +3426,19 @@ int stats_dump_errors_to_buffer(struct session *s, struct buffer *rep)
/* the function had not been called yet, let's prepare the
* buffer for a response.
*/
struct tm tm;
get_localtime(date.tv_sec, &tm);
chunk_printf(&msg, "Total events captured on [%02d/%s/%04d:%02d:%02d:%02d.%03d] : %u\n",
tm.tm_mday, monthname[tm.tm_mon], tm.tm_year+1900,
tm.tm_hour, tm.tm_min, tm.tm_sec, (int)(date.tv_usec/1000),
error_snapshot_id);
if (buffer_feed_chunk(rep, &msg) >= 0) {
/* Socket buffer full. Let's try again later from the same point */
return 0;
}
s->data_ctx.errors.px = proxy;
s->data_ctx.errors.buf = 0;
s->data_ctx.errors.bol = 0;
@ -3477,27 +3490,27 @@ int stats_dump_errors_to_buffer(struct session *s, struct buffer *rep)
chunk_printf(&msg,
" frontend %s (#%d): invalid request\n"
" src %s, session #%d, backend %s (#%d), server %s (#%d)\n"
" HTTP internal state %d, buffer flags 0x%08x\n"
" HTTP internal state %d, buffer flags 0x%08x, event #%u\n"
" request length %d bytes, error at position %d:\n \n",
s->data_ctx.errors.px->id, s->data_ctx.errors.px->uuid,
pn, es->sid, (es->oe->cap & PR_CAP_BE) ? es->oe->id : "<NONE>",
(es->oe->cap & PR_CAP_BE) ? es->oe->uuid : -1,
es->srv ? es->srv->id : "<NONE>",
es->srv ? es->srv->puid : -1,
es->state, es->flags,
es->state, es->flags, es->ev_id,
es->len, es->pos);
break;
case 1:
chunk_printf(&msg,
" backend %s (#%d) : invalid response\n"
" src %s, session #%d, frontend %s (#%d), server %s (#%d)\n"
" HTTP internal state %d, buffer flags 0x%08x\n"
" HTTP internal state %d, buffer flags 0x%08x, event #%u\n"
" response length %d bytes, error at position %d:\n \n",
s->data_ctx.errors.px->id, s->data_ctx.errors.px->uuid,
pn, es->sid, es->oe->id, es->oe->uuid,
es->srv ? es->srv->id : "<NONE>",
es->srv ? es->srv->puid : -1,
es->state, es->flags,
es->state, es->flags, es->ev_id,
es->len, es->pos);
break;
}

View File

@ -7278,6 +7278,7 @@ void http_capture_bad_message(struct error_snapshot *es, struct session *s,
es->src = s->cli_addr;
es->state = state;
es->flags = buf->flags;
es->ev_id = error_snapshot_id++;
}
/* return the IP address pointed to by occurrence <occ> of header <hname> in

View File

@ -43,6 +43,7 @@
int listeners; /* # of proxy listeners, set by cfgparse, unset by maintain_proxies */
struct proxy *proxy = NULL; /* list of all existing proxies */
struct eb_root used_proxy_id = EB_ROOT; /* list of proxy IDs in use */
unsigned int error_snapshot_id = 0; /* global ID assigned to each error then incremented */
/*
* This function returns a string containing a name describing capabilities to