[Icecast] Monitor traffic/bandwidth by mountpoint

Klauss Fumuldavijus dnr at freemail.lt
Thu Aug 3 11:35:33 UTC 2006


i've found that simple arithmetics gives quite precise results
(code below was written on the fly, so don't carp about the coding)

<?php

function tag_remove($str) {
    return preg_replace("@<[\/\!]*?[^<>]*?>@si","",$str);
}

function get_data(){
$web=fopen("http://192.168.123.123:8000/status_stat.xsl",r);
$content=str_replace("\t","",str_replace("><","",stream_get_contents($web)));
fclose($web);
$z=tag_remove($content);
$good_z=str_replace("/","\n",str_replace("\n","",str_replace(" ","",($z)))) 
."\n";
$line_array = explode("\n", $good_z);
    foreach ($line_array as $id => $value) {
        if ($value) {
        $mount=substr($value,0,strpos($value,":"));
        $usr_count=substr($value,strrpos($value,":")+1);
        $quality=substr($value,strpos($value,":")+1,-strlen($usr_count)-1);
        echo "mount=$mount...traffic = ".($usr_count * $quality)."\n";
        }
    }
}

get_data();
?>

you can use firewall counters as well:
00010      9720       624042 count tcp from any to me dst-port 8000
00011      1335      1709227 count tcp from me 8000 to any




More information about the Icecast mailing list