如何在Nginx中查找字节_?
我使用这个模块计算nginx请求计数和字节输出 我可以看到代码中使用了字节,并且工作正常 代码段: ngx_http_记帐_处理程序(ngx_http_请求_t*r){ .. 统计->字节输出+=r->连接->发送; } 但是如何计算字节数?有线索吗?我检查了ngx_http_request_和ngx_connection_,它有“发送”数据,但没有接收数据。任何建议都会很有帮助如何在Nginx中查找字节_?,nginx,Nginx,我使用这个模块计算nginx请求计数和字节输出 我可以看到代码中使用了字节,并且工作正常 代码段: ngx_http_记帐_处理程序(ngx_http_请求_t*r){ .. 统计->字节输出+=r->连接->发送; } 但是如何计算字节数?有线索吗?我检查了ngx_http_request_和ngx_connection_,它有“发送”数据,但没有接收数据。任何建议都会很有帮助 感谢使用r->request\u length,就像在nginx core中对log模块变量所做的那样。我已经更新了
感谢使用r->request\u length,就像在nginx core中对log模块变量所做的那样。我已经更新了
ngx\u http\u记帐\u模块
,在支持中添加了字节
stats->nr_requests += 1;
+ stats->bytes_in += r->request_length;
stats->bytes_out += r->connection->sent;
ngx\u http\u计费模块的原始版本(v0.1)未在
中实现bytes\u
在v0.2中,该值被添加到stats变量中
stats->nr_requests += 1;
+ stats->bytes_in += r->request_length;
stats->bytes_out += r->connection->sent;
输出格式更改为以下代码,将字节添加到输出缓冲区中:
- 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
);
有关更多详细信息,请参见此处:
谢谢Maxim Dounin