3

I am interested in trying to get a side by side usage comparison of all the virtual hosts being served up by my apache server.

In the simplest case, I want to see a list (or bar chart) with each virtual host and the number of requests/traffic on that site.

I've been playing around with webalyzer and awstats but I haven't been able to compare multiple virtual hosts in the same infographic.

Anyone have any suggestions on tools for doing this (or how I might use the above tools to do so)?

3 Answers 3

1

Well generally when using virtual hosts I have different access logs for each virtual host. If this is the case and you just want hits:

wc -l foo_vhosts.access*

This counts the lines, which would be log entires, which is basically how many hits you got. But you should describe if you log to different files or not, and post an example log entry.

If you don't log to different files, and your logging format doesn't include %v in its format, you are kind of out of luck, unless you can correlate each uri to its virtual host.

1
  • I am actually logging to separate files, so the wc output gives me a reasonable top level view However, I was hoping to get a slightly more detailed view into how things break down, and I'd like to be able to do some visualization on this. I was hoping there was a log analysis package that parsed your log files and turned them into graphs. In other words - how can I do what webalizer/awstats does, but using a composite multi-site breakdown.
    – shreddd
    May 26, 2010 at 2:16
1

First you need to change your log format so the virtual host is recorded in each log entry. Something like the following will get you a Combined/Expanded format with the bonus of %v which is the virtual host name:

LogFormat "%h %v %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\"" LogServerName

Then when you must tell apache to use this log format. Something like the following can be added globally or to the individual virtual hosts (easier globally). In fact I usually have the above line and this one in a single file called /etc/httpd/conf.d/access_logging.conf:

CustomLog /var/log/httpd/global_access.log LogServerName

Once that is done, you will at least be able to key off of different Virtual Hosts. Then you can use something like petit or uniq to do the following.

cat /var/log/httpd/global_access.log | awk '{print $2}' | petit --hash

Also, you could use racecar to do bandwidth analysis with something like this. It might be a bit slow on large files, but it is quick and dirty.

for i in `cat /var/log/httpd/global_access.log | awk '{print $2}'`; do cat /var/log/httpd/global_access.log | grep $i | racecar; done

Link: http://crunchtools.com/software/petit/ Link: http://crunchtools.com/software/racecar/

-1

@kyle, cut -f 1 -d ' ' combinedlog|sort|uniq -c|sort -nr

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .