Unfortunately, I don't know of any existing way to get live response time data. Given that I'd expect it to be a rare occasion when you need to check such data, it seems likely that the performance cost it requires (i.e. additional processing/logging per request) does not seem justified. I'd suggest simply logging the response time data to your logs (e.g. like this) and run a shell script to parse a portion of your logs (and output a summary) when you are interested in the data.
The live statistics are not too difficult to come by - but getting response time with them is harder. The approaches below only provide raw data - they do not graph it for you.
If you can live without response time (e.g. just req/s - and a breakdown of # reading, writing, active, total connections, etc), use the HTTP Stub Status Module. It provides a text output of information that can be easily be queried and parsed. (To use this module, Nginx needs to be compiled with --with-http_stub_status_module
)
Sample Output:
Active connections: 291
server accepts handled requests
16630948 16630948 31070465
Reading: 6 Writing: 179 Waiting: 106
(The 3rd line is accepted connections, handled connections, accepted requests)
There is an interesting article on using this data to generate graphs with rrdtool, here.
If the response time data is particularly essential to you, it should be possible to modify the Stub Status Module. The code (only about 5kB actually) is in src/http/modules/ngx_http_stub_status_module.c
. For instance, there is a modification here that has the module output aggregated counts of HTTP status codes returned.
Lastly, if you just want response time. You could save the data to Memcached using the HTTP Memc Module. For the purposes of your histogram, you would essentially create 2 keys per second - base the key on the time (e.g. $time_local
) - one key to store a counter of the number of requests in that second, and one to store the average response time (or cumulative response time) - working with the $request_time
and/or $upstream_response_time
variables.
I am sure you can come up with an easy way of graphing the data, once you have it, but here are some possibly starting points:
- Have a script pull the data (from stub, or memcached, etc) and generate ascii bars (e.g. like this), use
watch
to monitor the output of the script.
- If your server has PHP (and you willing to use it (not the ideal scripting language)), consider modifying this script.
- Finally, perhaps consider gnuplot (output
as_ascii
), although it seems excessive for the purpose.