#!/usr/bin/perl
my $pid = fork();
if($pid!=0){
exit 0;
}
use strict;
$SIG{TERM} = sub {exit 0;}; # I know it's dirty
my $html="/srv/www/htdocs/tcshape/index.htm"; #File that will be create for show stats
my $refreshRate="60"; #in Seconds
my $InetDev="ppp0"; #our Inet Device
my $LocalDev="eth0"; #our Local net Device
#Programms
my $TC="/usr/sbin/tc";
my $IFCONFIG="/sbin/ifconfig";
my $GREP="/bin/grep";
my $CUT="/usr/bin/cut";
if(!-f $TC){print "$TC not exist!\nexit now!\n";exit 1;}
if(!-f $IFCONFIG){print "$IFCONFIG not exist!\nexit now!\n";exit 1;}
if(!-f $GREP){print "$GREP not exist!\nexit now!\n";exit 1;}
if(!-f $CUT){print "$CUT not exist!\nexit now!\n";exit 1;}
my $cmd="$TC -s -d class show dev $InetDev";
#mldonkey must be runnig on the same machine
#my $MLinternIP=`$IFCONFIG $LocalDev |$GREP inet| $CUT -d : -f 2| $CUT -d\\ -f1`;
#$MLinternIP=~ s/\n//g;
my $html_head="
QoS Status Bandbreitenverteilung fur Upload:
";
#Table Head
my @order=("name","sendrate","sent","pkts","dropped","overlimits","parent","leaf","rate","ceil","prio","quantum");
while (1){
my %classes;
open(PIPE, $cmd."|") or die "Fehler in Pipe: $!\n";#
my $lastclass;
while(my $input = ){
if($input=~ /^class/){
my @tmp=split(/ /,$input);
$lastclass=$tmp[2];
}
$classes{$lastclass}.=$input;
}
close(PIPE) or die "Fehler in Pipe: $!,$?\n";
open(STATS,">$html")or die "Error open File $html : $!\n";#
print STATS $html_head;
print STATS "
";
for(my $i=0;$i<=$#order;$i++){
print STATS "
".uc($order[$i])."
";
}
print STATS "
\n";
foreach my $key (sort { $a cmp $b} keys %classes){
$classes{$key}=MakeParam($classes{$key});
my %row=%{$classes{$key}};
print STATS "