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.0To 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 installTo 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 9th, 2007 at 2:23 am
[...] Read it here. [...]
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]
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
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 ???
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.