Browse Source

[mod_accesslog,mod_rrdtool] HTTP/2 basic accounting

Note: rrdtool counts do not include HTTP/2 protocol overhead.
Continue to count mod_rrdtool per request rather than per connection
so that data is updated after each request, rather than aggregated
to the end of a potentially long-lived connection with many keep-alives.
master
Glenn Strauss 1 year ago
parent
commit
d4937e29f1
  1. 12
      src/mod_accesslog.c
  2. 6
      src/mod_rrdtool.c

12
src/mod_accesslog.c

@ -982,7 +982,9 @@ static int log_access_record (const request_st * const r, buffer * const b, form
case FORMAT_BYTES_OUT_NO_HEADER:
{
off_t bytes = con->bytes_written - r->bytes_written_ckpt;
off_t bytes = r->http_version <= HTTP_VERSION_1_1
? con->bytes_written - r->bytes_written_ckpt
: r->write_queue->bytes_out;
if (bytes > 0) {
bytes -= (off_t)r->resp_header_len;
buffer_append_int(b, bytes > 0 ? bytes : 0);
@ -1022,7 +1024,9 @@ static int log_access_record (const request_st * const r, buffer * const b, form
break;
case FORMAT_BYTES_OUT:
{
off_t bytes = con->bytes_written - r->bytes_written_ckpt;
off_t bytes = r->http_version <= HTTP_VERSION_1_1
? con->bytes_written - r->bytes_written_ckpt
: r->write_queue->bytes_out;
if (bytes > 0) {
buffer_append_int(b, bytes);
} else {
@ -1032,7 +1036,9 @@ static int log_access_record (const request_st * const r, buffer * const b, form
}
case FORMAT_BYTES_IN:
{
off_t bytes = con->bytes_read - r->bytes_read_ckpt;
off_t bytes = r->http_version <= HTTP_VERSION_1_1
? con->bytes_read - r->bytes_read_ckpt
: r->read_queue->bytes_in + (off_t)r->rqst_header_len;
if (bytes > 0) {
buffer_append_int(b, bytes);
} else {

6
src/mod_rrdtool.c

@ -424,8 +424,14 @@ REQUESTDONE_FUNC(mod_rrd_account) {
rrd_config * const rrd = p->conf.rrd;
if (NULL == rrd) return HANDLER_GO_ON;
++rrd->requests;
if (r->http_version <= HTTP_VERSION_1_1) {
rrd->bytes_written += (r->con->bytes_written - r->bytes_written_ckpt);
rrd->bytes_read += (r->con->bytes_read - r->bytes_read_ckpt);
}
else {
rrd->bytes_written += r->write_queue->bytes_out;
rrd->bytes_read += r->read_queue->bytes_in;
}
return HANDLER_GO_ON;
}

Loading…
Cancel
Save