Nginx: Show active connections

Here is something I stumbled upon some time ago and did put it on my “To do later when I have more time” list.

It’s nothing that will change the world as we know it, but it will give you some statistics about your NGINX server.

NGINX has a module called  HttpStubStatusModule which provides you statistics about number of requests handled and  connections made to your nginx server.

Today I got a few minutes over and I decided it was time to test it on one of my Virtual Private Servers.

First of all you need to check if your nginx installation has the module compiled, check it by running “nginx -V“:

if you have this “–with-http_sub_module” option in configure arguments, you are good to go. The results might look something like this

(the configure arguments part above is incomplete, it should contain alot more. I’ve shortened it for readability).

So, now that we have established that the module is available it’s time to edit your nginx configuration file.

In my case, using debian and MINSTALL, I decided to add it to the default.conf file found in /etc/nginx/hosts.d/

Add this into the server block

Save and restart nginx. Test it

 

And some explanation of the output

So what can we do with this information? It’s not that interesting when presented as pure text.

While reading about the HttpStubStatusModule module I noticed a link to a webpage that took advantage of this status module and used rrdtool to create some nice graphics from the result.
Now that is something all people love, graphs!

Read the instruction on how to use rrdtool here.

2 comments for “Nginx: Show active connections

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.