470,864 Members | 1,965 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,864 developers. It's quick & easy.

Check my bandwidth usage?

Is there a way to check my site's bandwidth usage via PHP? I'd like to
"gracefully bail" if I start to get near my host's limit. Its running on a
shared Linux box, on Apache 1.3.31 and PHP v4.3.3 as a module.

Thanks.

--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Jul 17 '05 #1
6 5786
FLEB wrote:
Is there a way to check my site's bandwidth usage via PHP? I'd like to
"gracefully bail" if I start to get near my host's limit. Its running on a
shared Linux box, on Apache 1.3.31 and PHP v4.3.3 as a module.


Do you have access to the raw site logs for your site only that's in an area
accessible by your PHP script? If so you can parse that for the outbound
data sent for each request.

If they're limiting the amount of bandwidth you're allowed in a month then
don't they have some sort of traffic meter you can check this yourself?

--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2
Regarding this well-known quote, often attributed to Chris Hope's famous
"Wed, 16 Jun 2004 14:53:02 +1200" speech:
FLEB wrote:
Is there a way to check my site's bandwidth usage via PHP? I'd like to
"gracefully bail" if I start to get near my host's limit. Its running on a
shared Linux box, on Apache 1.3.31 and PHP v4.3.3 as a module.


Do you have access to the raw site logs for your site only that's in an area
accessible by your PHP script? If so you can parse that for the outbound
data sent for each request.

If they're limiting the amount of bandwidth you're allowed in a month then
don't they have some sort of traffic meter you can check this yourself?


They monitor my traffic, and I can look up the number through CPanel. I
just don't know where to get to that number in an automated manner, so the
site on its own can, for instance, degrade images or reroute if my
bandwidth is almost gone.

--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Jul 17 '05 #3
FLEB wrote:
Regarding this well-known quote, often attributed to Chris Hope's famous
"Wed, 16 Jun 2004 14:53:02 +1200" speech:

FLEB wrote:

Is there a way to check my site's bandwidth usage via PHP? I'd like to
"gracefully bail" if I start to get near my host's limit. Its running on a
shared Linux box, on Apache 1.3.31 and PHP v4.3.3 as a module.


Do you have access to the raw site logs for your site only that's in an area
accessible by your PHP script? If so you can parse that for the outbound
data sent for each request.

If they're limiting the amount of bandwidth you're allowed in a month then
don't they have some sort of traffic meter you can check this yourself?

They monitor my traffic, and I can look up the number through CPanel. I
just don't know where to get to that number in an automated manner, so the
site on its own can, for instance, degrade images or reroute if my
bandwidth is almost gone.


is cpanel a webpage? What is your OS?

Michael.
Jul 17 '05 #4
Michael Austin wrote:
is cpanel a webpage?**What*is*your*OS?


Google is your friend: http://www.google.com/search?q=cpanel

First link on the results page.

--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #5
FLEB <so*********@mmers.and.evil.ones.will.bow-down-to.us> wrote in message news:<1j*******************************@40tude.net >...
Is there a way to check my site's bandwidth usage via PHP? I'd like to
"gracefully bail" if I start to get near my host's limit. Its running on a
shared Linux box, on Apache 1.3.31 and PHP v4.3.3 as a module.


I was also searching for similar stuff and found here
<http://www.xpenguin.com/calcband.php>

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #6
FLEB <so*********@mmers.and.evil.ones.will.bow-down-to.us> wrote in message news:<1j*******************************@40tude.net >...
Is there a way to check my site's bandwidth usage via PHP? I'd like to
"gracefully bail" if I start to get near my host's limit. Its running on a
shared Linux box, on Apache 1.3.31 and PHP v4.3.3 as a module.

Just another thought, if all the files are in PHP, output buffering _may_ help.

<?php
function CalcBandwidth($buffer)
{
$file_size = strlen($buffer);
//store the file size in DB or file
return ($buffer);
}
ob_start('CalcBandwidth');
?>

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Marcus | last post: by
1 post views Thread by Richard K Bethell | last post: by
2 posts views Thread by Sven | last post: by
3 posts views Thread by Raj | last post: by
reply views Thread by brett | last post: by
reply views Thread by rn5a | last post: by
8 posts views Thread by FrobinRobin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.