[master] 4a18350 Added %I and %O formatters to varnishncsa
Martin Blix Grydeland
martin at varnish-software.com
Tue May 27 13:06:17 CEST 2014
commit 4a18350b045b945dfc0b22eab2585c8c8e11ba92
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Tue May 27 12:37:10 2014 +0200
Added %I and %O formatters to varnishncsa
This adds %I and %O formatters to varnishncsa, which are total bytes
received and total bytes sent. These are similar to the same
formatters in apache (with mod_logio). Useful for bandwidth accounting.
Patch by: David Robertson
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 2162118..5aa0361 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -45,6 +45,8 @@
* %b Length of reply body, or "-"
* %{Referer}i Contents of "Referer" request header
* %{User-agent}i Contents of "User-agent" request header
+ * %I Total bytes recieved from client
+ * %O Total bytes sent to client
*
* Actually, we cheat a little and replace "%r" with something close to
* "%m http://%{Host}i%U%q %H", where the additional fields are:
@@ -95,6 +97,8 @@ enum e_frag {
F_h, /* %h Host name / IP Address */
F_m, /* %m Method */
F_s, /* %s Status */
+ F_I, /* %I Bytes recieved */
+ F_O, /* %O Bytes sent */
F_tstart, /* Time start */
F_tend, /* Time end */
F_ttfb, /* %{Varnish:time_firstbyte}x */
@@ -574,6 +578,12 @@ parse_format(const char *format)
case 'U': /* URL */
addf_fragment(&CTX.frag[F_U], "-");
break;
+ case 'I': /* Bytes recieved */
+ addf_fragment(&CTX.frag[F_I], "-");
+ break;
+ case 'O': /* Bytes sent */
+ addf_fragment(&CTX.frag[F_O], "-");
+ break;
case '{':
p++;
q = p;
@@ -783,6 +793,8 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[],
break;
case SLT_ReqAcct:
frag_fields(b, e, 5, &CTX.frag[F_b], 0, NULL);
+ frag_fields(b, e, 3, &CTX.frag[F_I], 0, NULL);
+ frag_fields(b, e, 6, &CTX.frag[F_O], 0, NULL);
break;
case SLT_Timestamp:
if (isprefix(b, "Start:", e, &p)) {
More information about the varnish-commit
mailing list