Measuring bandwidth output to a folder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Measuring bandwidth output to a folder

Post by genetix »

I'm working on a new file management system and I have run into a fork!

I can either count my clients "bandwidth" by page views or actual bandwidth. I have decided to use both(having it differ between hosting packages for beginners or experts).

Whats the easiest way to track the bandwidth on a folder? My clients each have a root folder(their username) on my hosting section of my webserver. Is there a program available which sits in the background on my server and monitors specified folders?
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

I was just snooping through my Apache logs and found a very easy way to count page views without adding scripts to every page a client has. Is there a way I can multiply the size of a page by how many times its view to get bandwidth or is that way off the island?

(Sorry about refering to an island but right now it has been blizarding literally ALL day and I can't keep the 4 foot snow bank off my driveway. I shovel every 3 hours and it takes me 2 hours to get rid of all the snow. Thank god for neighbours who have enough snowblowers that they do the street on the way to my house....)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I think that's how most of the other bandwidth analyzers work (outside of creating a plugin for the server, but then it's more and more specialized. :)
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

Do you know of any places that may have documentation on how its done? I'm guessing its probably not just a matter of multiplying page views by page size. That would seem to simple...

Thanks for the quick reply to! Your everywhere man its AWSOME! Thanks for the help in advance.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

i smoke crack rocks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

wonderfully informative shiz. :?

what I would do is using the expanded access log file, I'd group the uri's requested and sum each of their bytes sent information.. instead of multiplying (since the size of uri's can change quite easily, esp on a php'd site..:))
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Yeah shiz... you just couldn't contain telling us that?

Enjoy ;-) LOL :P
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Yeah you will want to just count the transfer sizes in the apache logs, as if you just multiply the page hits by page size you cant take into account that certain images and css files will be in cache.
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

What file does Apache store the information in? I'm guessing its under the apache logs folder in the file access?

If it is under the access file what column is it in?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the ~standard log I have has a quoted string (preceeded by the timestamp) that contains the http request. After that is the http response code sent back. The number following this is the bytes sent back. Beware that when no content is sent back, Apache typically will place a dash (minus) instead of zero. Also beware that the bytes sent is content only. Not header information, packet sizes or anything to that fact. So your numbers will be off unless you start tracking your header sizes too.. :)
User avatar
carlmcdade
Forum Newbie
Posts: 24
Joined: Thu Dec 02, 2004 2:19 am
Location: sweden

Post by carlmcdade »

The easiest way that I know of to get Apache/webhost to correctly measure traffic to a folder is to set a subdomain name to that folder using cpanel or the like.
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

carlmcdade wrote:The easiest way that I know of to get Apache/webhost to correctly measure traffic to a folder is to set a subdomain name to that folder using cpanel or the like.
I'm using this for my own control panel though. Thats the problem.
http://www.webdummy.net/serverpro/login.php
username: demo
password: demo
User avatar
genetix
Forum Contributor
Posts: 115
Joined: Fri Aug 01, 2003 7:40 pm
Location: Sask, Regina
Contact:

Post by genetix »

It turns out this is going to be a lot harder than I though with my current setup.

Are there any programs that "stand behind" apache and logs activity? What do other systems like CPanel or Plesk use?

*EDIT*
I found a few programs to detect bandwidth but I couldn't find any that watch the bandwidth output on a group of root folders.

To make matters worse I need to be able to add users from a internet script(admin part of my control panel). I also need one that logs the bandwidth in a txt or ini file so I can select it.

I'm starting to think I may need to ask a friend a REALLY big favour...
Post Reply