PDA

View Full Version : mod for Arthur's bandwidth script?


Monty
05-31-2005, 12:37 PM
it doesn't work correctly over the million hit per day point. It sure is handy, and a fix would be appreciated.

http://2coolfishing.com/screenshot4.jpg


#!/usr/local/bin/perl

# bandwidth.cgi

print <<HEADER;
Content-type: text/html

<HTML>
<HEAD><TITLE>Bandwidth usage</TITLE></HEAD>
<BODY>
<PRE>

HEADER

print "Bandwidth used:\n";
$directory = $ENV{"DOCUMENT_ROOT"};
open (BW, "$directory/stats/www-stats.hist");
while (<BW>) {
chomp;
if (substr($_,0,3) eq "DAY") {
@fields = split(/[ ]+/);
printf "Day: %6s %4.4f MB / %4.4f GB\n", $fields[1], $fields[7]/1048576, $fields[7]/1073741824;
$monthly_total += $fields[7];
}
if (substr($_,0,3) eq "MON") {
@fields = split(/\s+/); #RICH'S MOD HERE
#@fields = split(/[ ]+/);
printf "Month: %10s %4.4f GB\n", $fields[1], $fields[7]/1073741824;
}
}
printf "Used so far this month: %4.4f GB\n", $monthly_total/1073741824;

print <<FOOTER;
</PRE>
</BODY>
</HTML>

FOOTER

Arthur
05-31-2005, 12:40 PM
Hi Mont,

Change line 21 to;
@fields = split(/\s+/);

That should do the trick.

Arthur

Monty
05-31-2005, 01:28 PM
That seems to have fixed it, but the bandwidth I show using it is 171.1663 GB and in my CNC panel it shows 165.765 gigabytes (I like the CNC version, better, lol)