[MEDIUM] implement the CSV output for the statistics
It is now possible to get CSV ouput from the statistics by
simply appending ";csv" to the HTTP request sent to get the
stats. The fields keep the same ordering as in the HTML page,
and a field "pxname" has been prepended at the beginning of
the line.
diff --git a/src/proto_http.c b/src/proto_http.c
index 82b8cea..7077df5 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -3387,7 +3387,8 @@
}
else if (s->data_source == DATA_SRC_STATS) {
/* dump server statistics */
- int ret = stats_dump_http(s, s->be->uri_auth, 0);
+ int ret = stats_dump_http(s, s->be->uri_auth,
+ (s->flags & SN_STAT_FMTCSV) ? 0 : STAT_FMT_HTML);
if (ret >= 0)
return ret;
/* -1 indicates an error */
@@ -4694,6 +4695,15 @@
}
}
+ h = t->req->data + txn->req.sl.rq.u + uri_auth->uri_len;
+ while (h <= t->req->data + txn->req.sl.rq.u + txn->req.sl.rq.u_l - 4) {
+ if (memcmp(h, ";csv", 4) == 0) {
+ t->flags |= SN_STAT_FMTCSV;
+ break;
+ }
+ h++;
+ }
+
/* we are in front of a interceptable URI. Let's check
* if there's an authentication and if it's valid.
*/