MrtgStats - mrtg-compatible statistics

Introduction

The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network-links. It is widely used around the world to generate html pages containing gif images which provide a live visual representation of this traffic. MRTG is mainly a Swiss open-source product by Tobias Oetiker <oetiker@ee.ethz.ch> and Dave Rand <dlr@bungi.com> from the University of Zurich. Check http://www.mrtg.org/ for how to download and install MRTG.

MrtgStats is a small module which can query a running Alkaline and output MRTG-compliant statistics, which can be graphed using MRTG. You must be running Alkaline 1.3.0904.0 or later.

MRTG produces fully configurable and customizable graphics, such as shown in Figure 8-1 .

Installation

Download and install MRTG from http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html .

The MrtgStats syntax is the following:
mrtgstats server:port username password xml-field
The server runs Alkaline on the specified port. The username is the one to access the admin section (root or alkaline-manage), so is the password. The xml-field defines the source data that is being monitored.

You can query the following xml data:

Table 8-1. Performance Counters
/alkaline/server/pool/uptime server uptime in seconds
/alkaline/server/pool/threads current running threads
/alkaline/search/requests total search queries
/alkaline/search/rpm requests per minute
/alkaline/system/cpu/system kernel CPU time (not available on all platforms)
/alkaline/system/cpu/user user CPU time (not available on all platforms)
/alkaline/system/cpu/time shared kernel/user CPU time (not available on all platforms)

Make sure that you can access the performance counters in the admin section with this username and password pair.

Create a search.cfg configuration file in the same directory as other .cfg MRTG configuration files, which looks like this:
WorkDir: /home/webroot/mrtg

Title[fooaccess]: stats for www.foo.com:9420
# place on a single line
Target[fooaccess]: `mrtgstats
 www.foo.com:9420 alkaline-manage pass /alkaline/search/requests`
MaxBytes[fooaccess]: 100000
PageTop[fooaccess]: search count on www.foo.com
Options[fooaccess]: growright perminute
ShortLegend[fooaccess]:  
YLegend[fooaccess]: hits per minute
LegendO[fooaccess]:
LegendI[fooaccess]:  search count: 
Legend1[fooaccess]: search count
Legend2[fooaccess]:
 
Title[foothreads]: stats for www.foo.com:9420
# place on a single line 
Target[foothreads]: `mrtgstats
 www.foo.com:9420 alkaline-manage pass /alkaline/server/pool/threads`
MaxBytes[foothreads]: 100000
PageTop[foothreads]: thread count on www.foo.com
Options[foothreads]: growright gauge
ShortLegend[foothreads]:  
YLegend[foothreads]:
LegendO[foothreads]:
LegendI[foothreads]:  thread count: 
Legend1[foothreads]: thread count
Legend2[foothreads]: 
        

This is just an example. You should replace the paths and the parameters to mrtgstats by your own values.

Setup a crontab entry or a schedule entry under Windows NT such as:
# place on a single line
0,5,10,15,20,25,30,35,40,45,50,55 * * * *       
mrtg /home/webroot/mrtg/search.cfg > /dev/null 2>&1

MRTG will run mrtgstats every five minutes and create searchhits.html in the same directory as the rest of MRTG files with graphical output of the search engine statistics. These are the rpm (requests per minute) and the threads count, which closely matches your server's average load.