PDA

View Full Version : Tutoral question


outlet
7-17-05, 05:45 AM
I was looking at your bandwidth tips tutorial, and you suggested using this:

<?php
$total_size = 0;
$key = 0;
$units = array('Bytes', 'KB', 'MB', 'GB');

$file = file("/www/s/sdat/logs/access_log");
foreach ($file as $line) {
preg_match('/*\"*\"\ *\ (*).*/',$line,$matches);
if($matches;}// echo $matches[1].'<br />';}
}

while ($total_size >= 1024) {
$total_size = round($total_size/1024,2);
$key++;
}

echo $total_size.' '.$units;
?>

I got an error at first, until I removed the if($matches;}// echo $matches[1].'<br />';} line. but now, I get this: 0 Array as a result.

Anybody know how to fix it, or have a better php script for daily bandwidth usage?

outlet
7-17-05, 06:08 AM
I tried the first one also, and I get '0' bandwidth used. I correctly configured the paths in the scripts.

outlet
7-17-05, 06:17 AM
Ok, I figured out the first one, but can somebody tell me why it sometimes reports 0.000001GB instead of the actual bandwidth?

NMS
7-17-05, 02:55 PM
From which site did you get that script? Can you place the link here pls.

outlet
7-17-05, 07:36 PM
I got the script from the link in your sig, the offical help and tips page: http://help.powweb.com/info/bandwidth.php

I figured out that the logs were located elsewhere, but it still kind of odd that it if I refresh it several times, it will show 0.000001GB as the bandwidth used. Probably just a script issue.

extras
7-17-05, 10:42 PM
I wrote another one, several months ago.
http://check-these.info/tools/bw_cgi.txt

As it remembers the total transfer and use it on next the invocation
instead of counting from the beginning, it uses less resources and quicker.