0

I am using this module https://github.com/Lax/ngx_http_accounting_module for accounting nginx request count and byte out

I can see bytes_out is used in code and is working fine .

code snippet: ngx_http_accounting_handler(ngx_http_request_t *r){ .. stats->bytes_out += r->connection->sent; }

But how to calculate bytes_in? any clue? I checked ngx_http_request_s & ngx_connection_s which has 'sent' data but not the receive data. Any suggestion would be really helpful

Thanks

4

2 に答える 2

1

$ request_lengthログモジュール変数に対してnginxコアで行われるのと同じように、r->request_lengthを使用します。

于 2012-09-06T08:04:18.517 に答える
0

I've updated ngx_http_accounting_module, adding bytes_in support.

The original version(v0.1) of ngx_http_accounting_module didn't implement bytes_in.

In v0.2, this value is added to the stats variable.

     stats->nr_requests += 1;
+    stats->bytes_in += r->request_length;
     stats->bytes_out += r->connection->sent;

Output format is changed as following code, adding bytes_in: to the output buffer.

-    sprintf(output_buffer, "pid:%i|from:%ld|to:%ld|accounting_id:%s|requests:%ld|bytes_out:%ld",
+    sprintf(output_buffer, "pid:%i|from:%ld|to:%ld|accounting_id:%s|requests:%ld|bytes_in:%ld|bytes_out:%ld",
                 ngx_getpid(),
                 ngx_http_accounting_old_time,
                 ngx_http_accounting_new_time,
                 name,
                 stats->nr_requests,
+                stats->bytes_in,
                 stats->bytes_out
             );

For more detail, see here: https://github.com/Lax/ngx_http_accounting_module/tree/v0.2 .

Thanks Maxim Dounin!

于 2014-05-14T11:09:40.280 に答える