Monitoring apache & nginx using Monitis and M3




Apache and Nginx web servers both expose a very nice interface for polling the web server status via HTTP, providing you with useful counters for statistics and up-time.

Just to give you an idea, the status web page on Apache looks like this:




 Total Accesses: 1 Total kBytes: 3 Uptime: 316 
ReqPerSec: .00316456 BytesPerSec: 9.72152 
BytesPerReq: 3072 BusyWorkers: 1 IdleWorkers: 7 Scoreboard: _W______ 

The easiest way to obviously display it, would be using M3v3 regular expressions.

M3v3 to the rescue

M3v3 can analyze and display almost anything, Apache and Nginx included.
With M3v3 regular expressions support, displaying of the above is made very simple and both configuration files are here:

If you’ve clicked on any of these, you will see the instructions on how to setup your web server are inline (in the XMLs).
However, we’ll provide some explanation for the Apache one so we are sure we know what we are doing.

Apache Configuration

So as stated, if you enable mod_status on Apache using the following, you have your server status available at http://localhost/server-status:

 <IfModule mod_status.c> ExtendedStatus On 
<Location /server-status> SetHandler server-status
Order deny, allow Deny from all Allow from localhost
 ip6-localhost </Location> </IfModule> 

Make sure that you have proper ACLs on that, as you don’t need the whole world polling your web server status, which would not be secure.
Point your web browser there and make sure you get your web server status.

M3v3 integration

On the M3v3 side, things are rather simple and direct but let’s look at the section processing ‘ReqPerSec’, which obviously stands for ‘Requests Per Second’:

 integer number ReqPerSec: (\S+) 

In other words, we’ll just describe the line saying:

 ReqPerSec: VALUE 

The bold VALUE is what we’re after and M3v3 will describe it.


This is how it will look like on the dashboard:
Monitoring apache &amp; nginx using Monitis and M3

With M3 and Monitis anything can be monitored. Follow us on github and twitter.



You might also like