nginx 状态信息记录[HttpLogRequestSpeed]

这个模块可以找到所谓的网页瓶颈,但实际上用处不明显,Nginx 处理静态文件的能力已经可以说是无需置疑了,但我仍测试了一下该模块,官方提供了一个模块的源码和一个分析脚本,脚本是pl的。

模块下载地址:

###HttpLogRequestSpeed Module###http://wiki.nginx.org/File:Ngx_http_log_request_speed.tar.gz###Log Analyzer.pl###http://wiki.nginx.org/File:Log_Analyzer.tar.gz

重新/全新编译

[root@ipython nginx]# ./sbin/nginx -Vnginx version: nginx/1.7.5built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) TLS SNI support enabledconfigure arguments: ...[省略]  --add-module=../ngx_http_log_request_speed

Nginx 的配置

###该过滤器支持使用在location, server, http####http{  ##enable / disable##  log_request_speed_filter on;  ##timeout##  log_request_speed_filter_timeout 1;  ##Log 级别需要注意一下,吐出来的log就在error里面##  error_log  /software/var_temp/log/nginx/nginx_error.log error;}

日志示例(输出域名做了修改):

[root@ipython nginx]# tail -5 /software/var_temp/log/nginx/nginx_error.log 2014/11/25 15:12:50 [error] 11374#0: *103177 --- process request time: 13961 ms ---  while reading response header from upstream, client: 192.168.11.24, server: www.ipython.me, request: "GET /index.php HTTP/1.0", upstream: "fastcgi://unix:/dev/shm/php-cgi.sock:", host: "www.ipython.me"2014/11/25 15:12:57 [error] 11374#0: *103216 --- process request time: 19090 ms ---  while reading response header from upstream, client: 192.168.8.64, server: www.ipython.me, request: "GET /index.php?m=build&f=ajaxGetProjectBuilds&t=html&projectID=6&productID=9&varName=openedBuild&build=0&index=0&needCreate=true HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-cgi.sock:", host: "www.ipython.me", referrer: "http://www.ipython.me/index.php?m=bug&f=create&productID=9&extra=moduleID=0"2014/11/25 15:15:01 [error] 11374#0: *133586 --- process request time: 28808 ms ---  while reading response header from upstream, client: 192.168.8.64, server: www.ipython.me, request: "POST /index.php?m=bug&f=create&productID=9&extra=moduleID=0 HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-cgi.sock:", host: "www.ipython.me", referrer: "http://www.ipython.me/index.php?m=bug&f=create&productID=9&extra=moduleID=0"2014/11/25 15:15:02 [error] 11374#0: *103216 --- process request time: 76462 ms ---  while reading response header from upstream, client: 192.168.8.64, server: www.ipython.me, request: "GET /index.php?m=misc&f=ping&t=html HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-cgi.sock:", host: "www.ipython.me", referrer: "http://www.ipython.me/index.php?m=bug&f=create&productID=9&extra=moduleID=0"PROFILE: interrupts/evictions/bytes = 12095/260/113160

使用Log Analyzer.pl

[root@ipython request_speed_log_analyzer]# cat /software/var_temp/log/nginx/nginx_error.log | grep "process request" | ./analyzer.pl -rGET /index.php?m=story&f=ajaxGetProjectStories&t=html&projectID=6&productID=9&moduleID=0&storyID=0 HTTP/1.1 --- avg ms: 6554, value count: 1GET /index.php?m=misc&f=qrCode HTTP/1.1 --- avg ms: 6632, value count: 1GET /index.php?m=bug&f=ajaxLoadAssignedTo&t=html&projectID=6&selectedUser= HTTP/1.1 --- avg ms: 8451, value count: 1GET /index.php?m=bug&f=ajaxGetModuleOwner&t=html&moduleID=0&productID=9 HTTP/1.1 --- avg ms: 8590, value count: 1GET /index.php?m=bug&f=create&productID=9&extra=moduleID=0 HTTP/1.1 --- avg ms: 9204, value count: 1GET /index.php?m=task&f=ajaxGetProjectTasks&t=html&projectID=6&taskID=0 HTTP/1.1 --- avg ms: 9726, value count: 1GET /index.php HTTP/1.0 --- avg ms: 11073, value count: 226GET /index.php?m=build&f=ajaxGetProjectBuilds&t=html&projectID=6&productID=9&varName=openedBuild&build=0&index=0&needCreate=true HTTP/1.1 --- avg ms: 19090, value count: 1POST /index.php?m=bug&f=create&productID=9&extra=moduleID=0 HTTP/1.1 --- avg ms: 28808, value count: 1GET /index.php?m=misc&f=ping&t=html HTTP/1.1 --- avg ms: 76462, value count: 1 <--- THE WINNER##Help##[root@test-centos-24 request_speed_log_analyzer]# ./analyzer.pl -h-h : this help message-u : group by upstream-o : group by host-r : group by request

? 转载保留版权:IT辰逸 ? 《nginx 状态信息记录[HttpLogRequestSpeed]》 ? 本文链接地址:http://www.ipython.me/centos/nginx-httplogrequestspeed.html ? 本文版权采取:BY-NC-SA 协议进行授权,转载注明出处。除IT-Tools、News以及特别标注,本站所有文章均为原创。 ? 如果喜欢可以:点此订阅本站

仿佛一支飘荡在水上的华丽咏叹调。

nginx 状态信息记录[HttpLogRequestSpeed]

相关文章:

你感兴趣的文章:

标签云: