0

I've had a search and Google and found ways to monitor bandwidth per virtual host.

What I need is a way to monitor outgoing bandwidth (and eventually suspend) of sub folders of my document root. (I've got cron running a global bandwidth checker).

/srv/www/htdocs/user1files
/srv/www/htdocs/user2files

I don't want virtual hosts because I do not want to restart or "reload" Apache, every time I add a "new user".

I'm thinking the Apache access log may offer a way using awk to total all the /username1/:

10.65.10.77 - - [10/Mar/2013:10:20:17 +0000] "GET /user1files/upload.php HTTP/1.1" 200 10945
10.65.10.77 - - [10/Mar/2013:10:20:17 +0000] "GET /user1files/styles.css HTTP/1.1" 304 -

Many thanks in advance!

user127379
  • 473
  • 4
  • 11

1 Answers1

1

I think you already gave one answer yourselves.

In the log file entry you can read the download in bytes:

10.65.10.77 - - [10/Mar/2013:10:20:17 +0000] "GET /user1files/upload.php HTTP/1.1" 200 10945
10.65.10.77 - - [10/Mar/2013:10:20:17 +0000] "GET /user1files/styles.css HTTP/1.1" 304 -

The first file was 10945 bytes downloaded, the second none (http response 304 = not changed, ie the file is read from the browsers cache instead).

There are a number of log file analyzers available. The format is "Common Log Format" - you can probably find something if you search for it. Otherwise it wouldn't be too hard to script something yourselves. That would at least give you a good approximation.

Remember that quite often hosts are set up not to log things like jpegs and gifs - since the log files grow very very fast on large traffic sites. Such a limitation would render this analysis rather useless.

Jensd
  • 147
  • 9
  • Also, if you're looking for BW or connection monitoring / restrictions per location I'd suggest mod_qos - http://opensource.adnovum.ch/mod_qos/ – Ali Chehab Jun 24 '13 at 16:26