Skip to content

基于nginx-1.9.9版本修改stub_status模块,添加了响应时间总和。

License

Notifications You must be signed in to change notification settings

guisz/nginx-1.9.9-stub_status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  通过对stub_status的返回结果,不难发现。要想获得服务器的请求量,连接数很容易。而且我们可以写一个监控程序,每隔1s调用一下stub_status的location,在和上一秒做一个减法就可以得的nginx服务器QPS。但是遗憾的是,如何想要得到nginx处理请求的平均响应时间,就没法解决了。如果有人找你说你的http接口总是timeout,那就郁闷了。我的服务响应到底多长时间?这个问题就急需要解决。
  该程序就是在accepts handled requests后面加一个返回值,即服务器处理每个请求响应时间的和。这样要想看当前服务的响应时间,就只需要,和上一秒请求时间做差然后除以这一秒处理的handled值即可。
  
  
使用方法:
参考nginx官网 http://nginx.org/en/docs/http/ngx_http_stub_status_module.html

修改内容:
修改了 ngx_http_stub_status_module.c,ngx_event.h,ngx_event.c,三个文件。具体修改的代码行数。可用文件比对工具查看。

修改效果比对:
修改前:
Active connections: 1 
server accepts handled requests
 4 4 11 
Reading: 0 Writing: 1 Waiting: 0
修改后:
Active connections: 1 
server accepts handled requests
 1 1 63 13 
Reading: 0 Writing: 1 Waiting: 0 

其中 13 就是所有请求累计的响应时间。


About

基于nginx-1.9.9版本修改stub_status模块,添加了响应时间总和。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published