Using my bandwidth in my scripts

software development

#1

Is it possible to retrieve a variable somewhere so I can find out how much bandwidth I have and cut all my downloads once I detect a certain amount.

Thanks - Jutboy


#2

[quote]Is it possible to retrieve a variable somewhere so I can find out how much bandwidth I have and cut all my downloads once I detect a certain amount.
[/quote]

I wrote a cheesy little script a few months back that would graph the traffic on one of my domains on a daily basis.

The data that I used was stored in the domain’s log directory at /logs/yourdomainhere.tld/http/hits/.

This directory was being populated ever since I signed up last April, then mysteriously stopped working and had the old files deleted back on January 9th. After posting a similar question regarding the ‘new’ location of such traffic data here a week or so ago, it even more mysteriously started being populated again.

The files are named ‘bandwidth.YYYYMMDD’ and are added to the directory usually by 8:30 AM, server time.

There is one line in each of the bandwidth files, and in PHP it’s easy to retrieve the line, explode it, then use the fourth value, which is the byte total you want. You can iterate over whaterever timeframe you want to sum the data.

This, of course, assumes that this directory is working for you.

Here is an example of how I use the data to plot a traffic graph.

-JPB


#3

sweet…thank you so much…

Would you be able to send me your code to Justin at pleasesignup.com (of course replace the at with a @)

Thanks so much


#4

Sorry, my machine has been AWOL the last few days.

I’ll try to drop you a copy when I get home tonight.

I ran into a bug with it the other day. It seems I wrote it too simply and it defaults to 31-day months!

-JPB