Monitoring a specific virtualhost apache
December 29th, 2005Monitoring 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 |
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 !
Busy december
Décembre 29th, 2005J'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.
Flying tux
Décembre 13th, 2005Lors de mon vol Melbourne => Hong Kong, le système de vidéo de la business class avec Cathay Pacific est tombé en rade. Donc on a patienté pour que ça revienne et on a vu que le système tourne sous Linux. Le problème était visiblement que le serveur de fichier NFS était en rade et donc que les clients n'arrivaient pas à le monter...
Voila la photo... Je suis un peu passé pour un cinglé à prendre ça en photo dans l'avion.
Linux / Tux used by Cathay Pacific
Une autre jeunesse
Décembre 10th, 2005Une enquête qui ne m'étonne pas le moindre du monde pour avoir vu la manière dont se déroulent les soirées australiennes :
The study of 795 students over the age of 15 found almost 30 per cent had had unwanted sex as a result of being affected by alcohol or drugs
Traduction libre :
L'enquête portant sur 795 étudiants (plus de 15 ans) a trouvé que presque 30 pourcents d'entre eux ont eu des relations sexuelles non voulues provoquées par l'alcool ou la drogue.
Les soirées australiennes ont pas grand chose à voir à celle françaises... Ils sont bien plus relachées. L'alcool y coule à flot et il y est beaucoup plus facile (et normal) d'aller vers un (ou une) inconnu(e). Du grand n'importe quoi.
PS : Désolé si je ne blogue pas trop. Etant en France, j'ai pas mal de choses à faire en ce moment.
Publicité
Décembre 5th, 2005Ce billet est à caractère publicitaire.
Un bon ami à moi avec qui nous avons vadrouillé dans les provinces australes que sont l'Australie et la Nouvelle-Zélande vient de mettre en ligne ses photos...
Au programme :
* paysages australiens, néo-zélandais, français
* portraits
* Noir & Blanc
* quelques dessins
Ca vaut le coup d'être vu :
http://www.nguillen.com/
J'adore voir ses photos aux retours de vacances... Il nous offre un nouveau regard sur les paysages que l'on a pu voir ensemble.