[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.
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 89cb09b..8da98a6 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -161,6 +161,7 @@
 	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 @@
 
 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 */
 
diff --git a/src/dumpstats.c b/src/dumpstats.c
index da29809..a45d40a 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -3426,6 +3426,19 @@
 		/* 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 @@
 				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;
 			}
diff --git a/src/proto_http.c b/src/proto_http.c
index 8ca39c1..25421bc 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -7278,6 +7278,7 @@
 	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
diff --git a/src/proxy.c b/src/proxy.c
index 2082d09..0c6640e 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -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