bandwidth-old.phps

<?
// bandwidth.php
// Displays current average bandwidth usage taken from a rrdtool-database
// hellfairy - http://packy.se/
require("/home/erik/public_html/roundbytes.php");

$data = exec('/usr/bin/rrdtool fetch /var/www/rrdtool/cbl0.rrd AVERAGE -s -2min | grep -v "nan" | tail -n1 | cut -d" " -f2-');
$data = explode(' ', $data);
$traffic[down] = 0 + $data[0];
$traffic[up] = 0 + $data[1];

echo 'Current bandwidth usage - Download: '.roundbytes($traffic[down]).'/s Upload: '.roundbytes($traffic[up])."/s\n";

?>