12

We want to check the number of active connections without the module HttpStubStatusModule being installed.

What would be the equivalent Linux command?

As a base line, we test on a machine with HttpStubStatusModule installed first, e.g.

Active connections: 6146 <-- from HttpStubStatusModule

# netstat -an | grep :80 | wc -l
1266

# netstat -an | grep :443 | wc -l
25082

It seems to me that none of the above netstat give me the correct figure.

Any idea?

Howard
  • 2,135
  • 13
  • 48
  • 72

2 Answers2

15

Try excluding TIME_WAIT or grepping ESTABLISHED only

netstat -an | grep :443 | grep -v TIME_WAIT | wc -l

or

netstat -an | grep :443 | grep ESTABLISHED | wc -l
Chris Montanaro
  • 830
  • 1
  • 7
  • 8
  • The two commands give very different results. The first reports 3380 connections but the second - just 9. Why is that so? We use WebSockets. Can this be the reason? – Martin Dimitrov Sep 24 '19 at 08:02
  • This is very brittle. What if there is other software running on the machine, e.g. other monitoring systems ingress/egress which connects to 443? – whirlwin Apr 05 '22 at 07:41
0

Add the following to the nginx server block

   location /nginx_status {
        # Turn on stats
        stub_status on;
        access_log   off;
        allow all;
   }

we can check the connections status using the below URL

http://site_url/nginx_status
or
http://ip_address/nginx_status
Vinoth Rc
  • 172
  • 5