5

I'm looking for a way to monitor and record Apache traffic, separated by virtual host. I am currently using Munin to capture this and other data for the entire server however I can't seem to find a way to do this by vhost.

This link describes using a module called mod_watch which is apparently no longer in development:

http://www.freshnet.org/wordpress/2007/03/08/monitoring-apaches-virtualhost-with-munin/

The file that is listed as being compatible with Apache 2.x is reported to have problems with missing vhosts an reporting data correctly.

Does anyone know of a reliable way to determine real-time traffic per vhost? If I can find this it should be easy enough to write a new Munin plugin.

Edit:

What I'd really like to see is something similar to the Apache server-status scoreboard page with the number of connections / requests as that point in time separated by virtual host. This would give me the ability to check which vhost may be experiencing a spike in traffic in real time and would also provide the data needed for a Munin module (or some alternative performance monitoring / analysis system.)

Dave Forgac
  • 3,546
  • 7
  • 37
  • 48
  • 1
    So similar to what can be seen on the [apache.org](http://www.apache.org/server-status) `server-status` page? It shows vhosts, too. It's probably already there, you maybe just have to enable [ExtendedStatus](http://httpd.apache.org/docs/2.2/mod/mod_status.html#extendedstatus). – Alexander Janssen Oct 20 '12 at 10:15
  • Wow, I can't believe I overlooked that! @AlexanderJanssen, if you turn that into an answer I'll give you the bounty. – Dave Forgac Oct 20 '12 at 15:00

6 Answers6

3

what about having each vhost log to its own files, and then running log analysis against that?

i realize that's not fully real-time, but i don't see why you couldn't have something analyze your files more frequently than every day.

you could even use something or write something to monitor the logs, in real time, and generate graphs and other statistical data, if you were so inclined.

cpbills
  • 2,720
  • 18
  • 12
3

Individual virtual host logging does seem to be a way to solve this.

What is your use case for this? What data do you need to monitor or track about each virtual host?

Looks like there is a similar question here: munin to monitor apache hits on particular URLs

wickett
  • 148
  • 1
  • 8
3

You can create custom log file format with virtualhost name in it and then parse it realtime with GoAccess analyzer.

Kayla
  • 171
  • 1
  • 8
Andrei Mikhaltsov
  • 3,027
  • 1
  • 23
  • 31
1

mod_logio might be what you are looking for.

Hope this helps.

Marco Ramos
  • 3,120
  • 23
  • 25
1

mod_status already does that for you. You just have to make sure to use ExtendedStatus. To see an example how it'd look like, refer to apache.org's server-status page.

Alexander Janssen
  • 2,607
  • 16
  • 21
0

If you want to see how much memory/CPU resource PHP is using on each vhost you can do this with Apache suEXEC.

SuExec allows each CGI or SSI application to run under a different user. Use that alongside something like mod-fastcgi, and a PHP CGI interpreter, and you'll then be able to see each vhost's PHP usage separately in top or htop.

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
leftcase
  • 710
  • 3
  • 10
  • 18
  • This does look interesting but not all sites run PHP and what I'm really looking for is the number of open requests at a point in time. – Dave Forgac Oct 18 '12 at 19:40
  • The content of the linked page or even page title is not related to this question. Also those commands are danger for new linux users. – Milad Abooali Jul 09 '21 at 08:42