Article complet: Monitoring a specific virtualhost apache

29.12.05

Permalink 17:28:20, Categories: Administration, 583 words   English (EU)

Monitoring a specific virtualhost apache

Monitoring apache quite easy. There are plenty of solutions to do that. When it comes to monitore virtualhost one by one, it starts to be difficult. Of course, there is always the solution of using stats softwares but usually, it is not really time and doesn't give a quick and efficient overview.

Here comes mod_watch. A quite old module for Apache (1.3 & 2.0). Basically it monitores the incoming/outcoming traffic and the requests.

There is no debian package for this module. However, it is very easy to install.

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

Edit /etc/apache/modules.conf
And add in it :

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

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>

</IfModule>

Stop & start apache (not a restart)

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

For each virtualhost, you should be able to see a line containting this kind of data :
sylvestre.ledru.info 49 0 499775 39 9 1 0.000 136656176 3221223448

This means :


sylvestre.ledru.info target name
49 uptime in second
0 bytes received from requests
499775 bytes sent
39 number of requests received
9 number of documents sent
1 number of active connections
0.000 approx. 5 minutes average of bytes sent per second
136656176 bytes sent during the current 5 minutes period
3221223448 start time() of the current 5 minutes period

This data are meant to be retrieve by MRTG thought the mod_watch client in order to produce graphs, ie :

# ./mod_watch.pl http://sylvestre.ledru.info/watch-info
0
2012653
11.31
sylvestre.ledru.info


This returns the number of bytes out.
Or

# ./mod_watch.pl -f ifRequests,ifDocuments http://sylvestre.ledru.info/watch-info
241
80
13.02
sylvestre.ledru.info


This returns the number of requests and documents.

Finally, as the developer knows that ITs are lazy, he made a script which will automatically create an MRTG configuration file from the apache configuration (I made a small patch in order to monitore also the documents/requests with this script and fixes a bug with mrtg indexmaker)

wget http://sylvestre.ledru.info/howto/mod_watch/patch_apache2mrtg.diff
patch < patch_apache2mrtg.diff
Add Workdir: /path/to/www/ for the output dir
./apache2mrtg.pl /etc/apache/httpd.conf > /etc/vhosts_mrtg.cfg


Caution ! apache2mrtg.pl will parse ALL the virtualhost. Even those with htaccess login/password and then won't be able to access to the watch-info files. Remove them from the vhosts_mrtg.cfg file.

There is many solution to customize the value & data. Check out the documentation here : http://www.snert.com/Software/mod_watch/.

Advantages :
* Quite easy to install, configure & maintain
* Quite fast
* Make very easy the task to find which virtualhost takes all the bandwith.

Disavantages :
* Impact on the performance ?
* No monitoring of CPU / Memory
* Based on headers (ie, if I start a download of 200 mo and I stop at the beginning, it will count 200 mo... Problem Described here)

Next tasks :
* Patch the software to add CPU & Memory monitoring PER virtualhost or find a module which does that.
* Find a way to fix the headers issue.
* Add the total bytes transferts

Edit : Comments closed. Thank you spammers !

Permalink

Comments:

No Comments for this post yet...

Comments are closed for this post.

A frog around the world

Mon séjour en Australie s'est terminé... Un an et demi de bonheur ! Cependant, ce blog continue. Je continue à garder le contact avec le pays et je continue à partager mes expériences.
Pour plus d'infos sur l'Australie, mon carnet de voyage est aussi disponible.
D'autres carnets de voyage sur Kikooboo !

Janvier 2012
Lun Mar Mer Jeu Ven Sam Dim
<<  <   >  >>
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

Catégories


Linkblog

Syndiquez ce blog XML

What is RSS?

powered by
b2evolution