A frog around the world |
![]() |
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
# ./mod_watch.pl -f ifRequests,ifDocuments http://sylvestre.ledru.info/watch-info
241
80
13.02
sylvestre.ledru.info
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
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 !
J'ai un peu honte du peu de mises à jour sur mon blog mais je suis bien pris par mon retour en France entre les soirées, familles, fêtes, vacances au ski, etc... Pourtant, l'actualité australienne ne manque pas d'intérêts en ce moment... Entre l'exécution de l'australien Van Tuong Nguyen à Singapour début décembre, les émeutes à Sydney quelques jours après (rien à voir) il y avait de quoi faire quelques billets. Ca arrivera plus tard.
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 !
| 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 | |