Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've installed Nagios and Centreon, and I want to monitor the bandwidth and the number of visitors of each VirtualHost in Apache server. I've found check_http but it checks only if the virtualHost is on line.

Thanks

share|improve this question

1 Answer 1

up vote 1 down vote accepted

easy to ask the question, the answer is a bit more tricky, and the implementation wil be more difficult still.

One of the main reasons for having virtual hosts is so you can have multiple sites running off the same IP address - so in order to measure the actual bandwidth you'd need a stateful packet monitoring system like PasTMon - which is quite involved to set up / integrate.

A simpler solution would be to write the value to the Apache log file (%I,%O) along with the virtual host (%v).

For counting visitors, you'll need mod_usertrack - and log the value of the usertrack cookie (by default %{Apache}). Note that it is optional whether browsers accept / present cookies. A single user's session may appear from multiple remote hosts when connecting via load-balanced proxies while potentially multiple users may be accessing the site via the same proxy - so remote host (%h) is not an accurate indicator - but you might consider using this for cases where the cookie reported is always null.

You'll also need some tools to parse the logs and transform the raw data into something more meaningful. But implementing this in perl or awk (or...?) is trivial. You can configure Apache to pipe the logs direct to the program or write to a file then tail the file to feed the transformer.

Nagios is a realtime system monitor - and not ideally suited for monitoring/reporting on this kind of data. You might want to have a look at AWStats - although this really only works with offline data.

See also

http://httpd.apache.org/docs/2.0/mod/mod_usertrack.html

http://httpd.apache.org/docs/2.0/mod/mod_log_config.html

share|improve this answer
    
Thank you for your response, I will use the solution of Apache log and create a script to count bytes to calculate the bandwidth. For the number of users I will see that later. –  djoudi Sep 16 '10 at 15:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.