Freshnet.org


Monitoring Apache’s VirtualHost with Munin

Inserito in Tech stuff il March 8th, 2007

Munin is a monitoring tool that “surveys all your computers and remembers what it saw. It presents all the information in graphs through a web interface” using the excellent RDDTool
Munin configuration is beyond the scope of this paper, please refer to documentation on Munin site.
The default munin plugins use the apache mod_status module, that stores data from all the virtual hosts, like in picture below

Obviously it can be more interesting to have separate data for each virtual host.
Bjørn Ruberg wrote a munin plugin for this, using a quite old apache module, mod_watch.

There is no debian package for this module.
Lurking around I have found the source and it’s easy to install on Debian

apt-get install apache-dev
tar -zxvf mod_watch318.tgz
cd mod_watch-3.18
make install-dynamic

NB With apache2 you need mod_watch4

***************************************************************
How to build mod_watch for Apache 2.0

To build a DSO version of mod_watch for Apache 2.0, first
verify the configuration at the top of the Makefile.dso then
type:

make -f Makefile.dso build
make -f Makefile.dso install

To build a static version of mod_watch for Apache 2.0:

cd (path to)/apache_2.0.44
mkdir -p modules/com/snert
mv (path to)/mod_watch-4.2 modules/com/snert/watch
./buildconf
./configure \
–enable-watch \
… (your other configuration options) …
make install

***************************************************************

Edit /etc/apache/modules.conf
and add the line in it:

LoadModule watch_module /usr/lib/apache/1.3/mod_watch.so

Now edit /etc/apache/httpd.conf
Add:

<IfModule mod_watch.c>
# Allows the URL used to query virtual host data:
#
# http://www.snert.com/watch-info
#
<Location /watch-info>
SetHandler watch-info
Order allow,deny
Allow from hostname
</Location>


# Intended for debugging and analysis of shared memory
# hash table and weenie files:
#
# http://www.snert.com/watch-table
#

<Location /watch-table>
SetHandler watch-table
Order allow,deny
Allow from hostname
</Location>

<Location /watch-list>
SetHandler watch-list
Order allow,deny
Allow from hostname
</Location>


</IfModule>

Change hostname with the munin-node host ip (tipical localhost)

Stop & start apache

/etc/init.d/apache stop && /etc/init.d/apache start

Test from command line that all works correctly

./mod_watch.pl -f ifRequests,ifDocuments http://www.freshnet.org/watch-list/
65236
11851
14:59.59
SERVER

And now install the plugin

cp mod_watch /usr/share/munin/plugins/
cd /etc/munin/plugins
ln -sf /usr/share/munin/plugins/apache_watch apache_watch_bytes
ln -sf /usr/share/munin/plugins/apache_watch apache_watch_documents
ln -sf /usr/share/munin/plugins/apache_watch apache_watch_requestes

Finally restart munin-node

/etc/init.d/munin-node restart

Et voilà the result :) A graph for each virtual host

7 Responses to 'Monitoring Apache’s VirtualHost with Munin'

Subscribe to comments with RSS or TrackBack to 'Monitoring Apache’s VirtualHost with Munin'.


  1. on March 9th, 2007 at 2:23 am

    [...] Read it here. [...]

  2. Scott said,

    on April 18th, 2007 at 3:14 am

    Building this against apache 2.2.3 gives a error when restarting the server….

    [code]
    Cannot load /usr/local/apache2/modules/mod_watch.so into server: /usr/local/apache2/modules/mod_watch.so: undefined symbol: APR_STATUS_IS_SUCCESS
    [/code]

  3. mucsoo said,

    on June 15th, 2007 at 5:04 pm

    Forcing reload of web server (apache2)…apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/watch.load: Cannot load /usr/lib/apache2/modules/mod_watch.so into server: /usr/lib/apache2/modules/mod_watch.so: undefined symbol: shPrintFormat

  4. alex said,

    on June 20th, 2007 at 10:37 am

    Yep, this plugin doesn’t work for apache2, you get “Cannot load /usr/local/apache2/modules/mod_watch.so into server: /usr/local/apache2/modules/mod_watch.so: undefined symbol: APR_STATUS_IS_SUCCESS” or other problem…
    Any solution ???

  5. Derek said,

    on June 25th, 2007 at 7:53 pm

    Source for Apache 2.0 and 2.2 versions are available on the cacti forum
    http://forums.cacti.net/about15475.html

    Not that I’ve tried them.


  6. on September 10th, 2009 at 1:46 am

    [...] which I hadn’t done, but even then they were still lacking. I did some searching and found this blog post that looked to display pretty much exactly what I was after. Unfortunately most of the links to [...]

  7. Anonymous said,

    on November 2nd, 2009 at 11:34 am

    In debian lenny I got this error with mod_watch.pl:

    Bad arg length for Socket::pack_sockaddr_in, length is 0, should be 4 at /usr/lib/perl/5.10/Socket.pm line 214.

Leave a Reply