Monitoring Nginx with Munin

Munin is a free software networking and infrastructure monitoring system. We chose it because the configuration is simple and allows us to demonstrate the principles. You will certainly prefer to use the same monitoring solution that you use for your other needs. If you do not currently use anything that is not very probable, Munin is as good an option as any other to start with.

Munin was developed with easy extensibility via plugins in mind. It uses the famous RRDTool time series database that was first developed as part of MRTG but then found its way to many other free and open source software as the time series database and time-based graphs engine.

Installing Munin is not as easy as we wish it were but the process is thoroughly described in the online Munin guide http://guide.munin-monitoring.org/en/latest/installation/index.html. There is also a book about Munin published by Packt Publishing, Instant Munin Plugin Starter. It may be a little old but still contains enough relevant information.

Munin is also one of the monitoring systems that has plugins to parse the output from the Nginx http_stub_status module in its distribution. The plugins are available right after Munin installation and are supported as part of the release cycle of Munin.

The architecture of many network monitoring systems is very similar to a classic star topology system with a master that is responsible for drawing graphs, watching for events, and issuing alerts based on data provided by agents, each of which represent a host or a service. Munin agents are named nodes and installing Munin usually installs an instance of the Munin node on the same host as well. That sounds absolutely okay as the master host of a monitoring system should definitely be monitored itself. It is the node component that has integration with different software to get metrics that should be monitored. Munin plugins for Nginx are executable scripts that are run as part of the Munin node operation. The node process reports the data from those (and all the other) plugins to the Munin master, which has the interface for the administrators.

After successful installation of Munin, you will find all standard plugins in /usr/share/munin/plugins or some other directory depending on your distribution. There are two standard Nginx plugins in Munin 2.0.25—nginx_requests and nginx_status. Both of those plugins parse the output of the http_stub_status Nginx module and thus require the url environment variable to point to the stub_status output URL with a sane default of http://localhost/nginx_status. To switch the plugins on, you need to link them into /etc/munin with a command such as:

$ sudo ln -s /usr/share/munin/plugins/nginx_* /etc/munin/plugins/

You may also examine the contrib Nginx plugins available at https://github.com/munin-monitoring/contrib/tree/master/plugins/nginx. These are not installed by default, but are still part of the Munin source tree.

After restarting the Munin node running on the host, the metrics reported by Nginx are immediately available for this particular host. To check whether the plugins can successfully access Nginx and parse its stub_status, you can use these convenient commands:

$ sudo munin-run nginx_request
request.value 15
$ sudo munin-run nginx_status
total.value 2
reading.value 0
writing.value 1
waiting.value 1
$

Given that your Munin master and nodes are running, you will start to get updated graphs for Nginx metrics at once. A clean Munin without any past data will show something like this:

Monitoring Nginx with Munin

Adding more hosts to the Munin master is completely transparent, provided that those hosts run the node with Nginx plugins. All of the reported metrics will show up instantly and will get drawn and checked against limits, which also brings us to the next topic.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.240.252