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.
Configuration
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 192.168.1.5 # allow 192.168.1.5; deny all; }
Save and close the file. Reload nginx server:
# service nginx reload
OR
# nginx -s reload
Test it
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:
Where,
- 586 = Number of all open connections
- 9582571 = Accepted connections
- 9582571 = Handled connections
- 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
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 2 comments… read them below or add one }
Very interesting tips !
Thank for that ;) I’ll test it soon
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