NGINX is the new rising star among other web servers. In fact, NGINX is now the 2nd most widely used web server (22 million websites) in the world. NGINX fanboys will tell you no one can top their love of NGINX, because it succeeds in efforts to achieve high performance with small memory footprint. It makes NGINX suitable to deliver static content, to work as a reverse proxy, or even to run as a load balancer, all of the above in a fast and scalable way. Several well-known companies pick NGINX to power their sites, including WordPress and Github.
Konwningly NGINX is lightweight and powerful, a good system administrator will not simply install NGINX and hope for the best. Yes, a good systemadmin has an option to turn on NGINX’s stub_staus module, so that she can monitor NGINX servers and, make sure everything is running nice and smooth. The statistics include active connections, requests handled, keep-alive connections and more. Here is an example output from the stub_status module:
Active connections: 291 server accepts handled requests 16630948 16630948 31070465 Reading: 6 Writing: 179 Waiting: 106
However, the NGINX statistics above is not reader friendly. Can we do better? With Monitis‘ support, the answer is yes. Last time we showed you how to Integrate Apache Monitoring into Monitis.com; today we will show you how to integrate Monitis with NGINX. Let’s turn the cryptic data above into an eye-candy report in five simple steps:
Collect NGINX Statistics to Your Monitis account:
Figure 1: Monitis shows a nice graph for NGINX Stub Staus.
Figure 2: Monitis provides a cleaner output for NGINX Server Stats.
In a nutshell, the example here simply fetch your NGINX stats, and send them to your Monitis account periodically:
1. Install NGINX stub_status module.
2. Edit your nginx.conf.
Here we use port 80, and listen on localhost with address of nginx_status. server { listen 80; server_name localhost; location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } } That is, with the configuration above, you can view the original NGINX stats @ http://localhost/nginx_status
3. Start your NGINX Server.
4. Download the code and run the program.
On your windows command line, run the program like this:
monitis_nigix_stats.exe "[apikey]" "[secretkey]" "[monitorname]" "[minitortag]" "[nginx stub status url]"
For example, assume you already have a Monitis account:
monitis_nginx_stats.exe "14NAC40PIMSUEEBQFJOQL18T5U" "74H6U7A2DG71JU80QR48FEOPAL" "Nginx Monitor" "Nginx+Stub+Status" "http://localhost/nginx_status"
5. Log in to your Monitis account and start monitoring.
You can see a new custom monitor ready to be added. (Monitors->Manage Monitors->Custom Monitors). Check and add your new monitor to your dashboard.
Conclusion:
In this article, we demonstrate an enterprise solution in NGINX monitoring. In five steps, Monitis is able to organize the statistics into columns; you can also track data continuously with a nice graph. Furthermore, you can add as many custom monitors as you like, all in your Monitis dashboard. Get your free registration here, and monitor your NGINX servers effectively.
Happy NGINX monitoring!
The Monitis Team
—
External Scripts:
NGINX Monitoring in C#
https://github.com/monitisexchange/Monitis-Linux-Scripts/tree/master/nginx/csharp
NGINX Monitoring in Python
https://github.com/monitisexchange/Monitis-Linux-Scripts/tree/master/nginx/python
External Links for further information:
http://www.monitis.com/api/api.html#addCustomMonitor
https://www.monitis.com/sign-up