I beleive the stub module gives the number of requests since nginx was
last reloaded (or started). To get the number of rps, you have to query
the stub module each second and substract the old value from the current
Is there any other ways to do this automatically instead of manually
subtract ?! I want to see in live.
we have some command line ruby/perl scripts that do this, pretty simple.
If you wanted to do this “in” nginx, I guess the easiest way would be
using Lua that did a location_capture of stub_status and cached the
value ( using http://wiki.nginx.org/HttpLuaModule#ngx.shared.DICT
Or, have a script that polls nginx stub status every x seconds and
writes it out to a static file that nginx can serve.
I’d rather nginx just provide the raw data and I can slice and dice it
for my own needs.
Please remember that what you are looking for is a “human” value, as
opposed to the snapshot type of values the server can reliably provide.
The reason why nginx does not provide what you are looking for may be
that the server would have to provide several intervals to satisfy
everyone (second, millisecond, minute, hour, etc.), and that is neither
practical nor reliable. Such data could also be misleading, depending on
your use case. From a server point of view, the best thing to do was to
give a total number of requests served and let the admins do the math as
they see fit.
However, the stub status module provides easy-to-read data that you can
parse with a script in a loop, or such a script could dump the stats in
a database and you could then read that. That is the best long-term
solution to your problem. Please remember too that this database does
not need to be SQL, it could be RRD-based for example, or just plain
files, whatever suits you best.
If you are just interested in knowing Request per second and if you have
logging enabled then I would suggest using netcat. you just need to tail
the log file and then use the netcat to count the lines and it would
give you the details you need. Since the tail by default updates every 1
second you will get what you need.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.