[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.
This commit is contained in:
Glenn Strauss 2020-07-31 03:51:56 -04:00
parent afc2025d8e
commit d4937e29f1
2 changed files with 15 additions and 3 deletions

View File

@ -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 {

View File

@ -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;
}