If your team is managing the web servers for one of the busiest ecommerce site or a social media run site, its not quite easy to address all monitoring needs just by looking at the Nagios, Munin and other tools as they collect the data from server and then produce the infographics or send alerts.
Even if you don’t have these tools setup, its better to use tools that give visibility to real time data in a readable format. Take a look at the situation where your web server (Nginx) is failing to serve the pages of your PHP or Rails application hosted. If you don’t see the web service failing but the application not being able to load the sites (Ex: 502 error upstream was unable to serve the page), it is sure that the webserver needs to be checked for configuration optimization .
Ngxtop one such tool that you would like to use with your Nginx. This would get you a quick and easy access to incoming requests coming your way from various ip’s, help you see the URL’s, type of HTTP responses just like the way you use “top” command from which it darws the inspiration.
Following image gives you a quick look into the results.
Similarly, You have apachetop for Apache web service.
Ngxtop is maintained on github ( https://github.com/lebinh/ngxtop/ )
You can install Ngxtop using pip command as follows:
pip install ngxtop
Note: ngxtop is primarily developed and tested with python2 but also supports python3.
Example: Following command shows you the top ip’s and their request counts quickly.
$ ngxtop top remote_addr running for 20 seconds, 3215 records processed: 159.62 req/sec top remote_addr | remote_addr | count | |-----------------+---------| | 126.96.36.199 | 20 | | 188.8.131.52 | 16 | | 184.108.40.206 | 16 | | 220.127.116.11 | 16 | | 18.104.22.168 | 16 | | 22.214.171.124 | 16 | | 126.96.36.199 | 15 | | 188.8.131.52 | 15 | Note: If you want to restrict the output to a specific site to be monitored, you can use -l switch with the access log file path.
If you want to be very specific on the requests and the referrers you might want to try the following:
$ ngxtop -i 'status >= 400' print request status http_referer running for 2 seconds, 28 records processed: 13.95 req/sec request, status, http_referer: | request | status | http_referer | |-----------+----------+----------------| | - | 400 | - |
Tip: If you’re planning to monitor a apache access log, ngxtop allows you to do so. Try this:
$ tail -f /var/log/apache2/access.log | ngxtop -f common
The above results would surely help you guide your developers to nail the root cause for the slow applications, increased error rates, Ddos, application performance after the recent changes etc. These opportunities would help you kick start building DevOPS culture of OPS collaborating with Dev for performance optimization.
Want to learn more about how we can help you? Please feel free to contact us or leave us a comment below.