0

I am tasked with figuring out the bandwidth used per directory on a parent directory in a linux server. We are hosting 10+ different client sites in 10+ different directories, and want to figure out the bandwidth per each on a single host.

I'd like to record the bandwidth used into a central area (text file, SQL database) so that I can then query the data for reporting later. I am comfortable writing the saving logic in PHP or bash.

I assume that we attach some sort of custom log file in our .conf file, so that every time the page is loaded we determine the amount of assets (markup, images, etc) loaded for that single session and send that data to a database? I am trying to find someone much smarter than myself to determine how to best architect and roll this out so that we don't slow down the server and get the basic data needed.

Zach Smith
  • 280
  • 2
  • 10

1 Answers1

0

The easiest way I can think of going about this would be to make use of your web server's logging mechanism to keep track of the bytes sent in response to each request.

For example, if you're using Apache, you can make use of mod_log_config to add a CustomLog directive to create logs that look something like this:

Bytes     URL
485       /client1/index.php
45        /client1/favicon.ico
632       /client2/home.html
132       /client2/script.js

Once you have the data, you can write a simple script to calculate the bandwidth for each client based off the request URL.

slightly_toasted
  • 732
  • 3
  • 13