Monitoring Apache’s VirtualHost with Munin

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

March 8th, 2007 Posted in Tech stuff

5 Responses to “Monitoring Apache’s VirtualHost with Munin”

  1. Monitoring Apache’s VirtualHost with Munin « /home/kOoLiNuS Says:

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



  2. Scott Says:

    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 Says:

    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 Says:

    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 Says:

    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.



Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress | Blue Weed by Blog Oh! Blog | Entries (RSS) and Comments (RSS).