≡ Menu

nginx: See Active connections / Connections Per Seconds

How do I monitor my nginx server status and connections requests per seconds under Linux or Unix like operating systems?

nginx server has a module called HttpStubStatusModule. This module provides the ability to get some status from nginx. You will get the following information:

  1. Number of all open connections.
  2. Stats about accepted connections.
  3. Connections per second and so on.


Edit nginx.conf file:
# vi nginx.conf
Add or append the following in context location:

   location /nginx_status {
        # Turn on stats
        stub_status on;
        access_log   off;
        # only allow access from #
        deny all;

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

Test it

Open a web-browser and type the following url:
Sample outputs:

Fig.01: nginx Status Monitor with HttpStubStatusModule

Fig.01: nginx Status Monitor with HttpStubStatusModule


  1. 586 = Number of all open connections
  2. 9582571 = Accepted connections
  3. 9582571 = Handled connections
  4. 21897888 = Handles requests

How do I calculate connections per seconds?

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
Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 6 comments… add one }
  • Centreon March 3, 2013, 3:42 pm

    Very interesting tips !
    Thank for that ;) I’ll test it soon

  • Julien March 9, 2013, 9:31 pm

    Have you tried logtop ?

    logtop provide live statistics on a “tail -f any_log_file” :
    For example, to get your top articles if your articles contains the pattern /article/ :
    tail -f /var/log/*/access.log | grep –line-buffered /article/ | logtop

    Or to get top IPs :
    tail -f /var/log/*/access.log | cut -d’ ‘ -f1 | logtop
    (You may prefer awk ‘{print $1; fflush();}’ if you have a very slow traffic cause cut is buffering)

    logtop is in Debian testing and backports, or : https://github.com/JulienPalard/logtop

  • Paul September 17, 2013, 4:28 pm

    Works like a charm, thanks.

    Any idea if it’s possible to Ajax / real-time this data?

  • jaydeep June 8, 2015, 6:50 am

    Hi all,

    I have done limited connections configuration to the nginx.

    But i want ot know how to test the following configurations

    For example i have limited one connection per ip in the nginx.

    But if I opened 2 tabs from the browser and open the web even it is accessing

    So i need to know how we can test the configurations for following
    1). limited connections per ip
    2). limited rate
    3). and I have to access the particular files from the php file only, if we access directly it should not show
    suppose any documents, audio and video files should not play directly, if i access through php file it should show.
    I have attached my nginx.conf file png.

  • Francesco April 21, 2016, 8:18 pm

    curl --silent|sed '3q;d'|awk '{ print "echo " $3"/"$2"|bc -l" }'|sh

  • test May 5, 2016, 8:45 pm

    Thank you!

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , ,