Nginx Display Active Connections

How to watch nginx server status and connections requests per second under Linux or Unix like operating systems? For such a task nginx server has a module called HttpStubStatusModule. This module provides the ability to get some status from nginx. You will get the following information:

  • Number of all open connections.
  • Stats about accepted connections.
  • Connections per second and so on.

Configure HttpStubStatusModule

Edit nginx.conf file:
# vi nginx.conf

Add or append the following in context location:

Save and close the file. Reload nginx server:
# service nginx reload

OR

# nginx -s reload

Watch Nginx Active Connections

Open a web-browser and type the following url:
http://your-domain-name-here/nginx_status

OR
http://ip.address.here/nginx_status

Sample outputs:
nginx-display-active-connections

Where,

586 = Number of all open connections
9582571 = Accepted connections
9582571 = Handled connections
21897888 = Handles requests

How to calculate connections per second?

Requests per connection = handles requests / handled connections
Requests per connection = 21897888/9582571 (pass this to bc -l using echo ‘21897888/9582571’ | bc -l command)
Requests per connection = 2.28

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com