From: "sufcrusher" <sufcrusher@zonnet.nl>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] Testing traffic control
Date: Sat, 26 Apr 2003 15:52:35 +0000 [thread overview]
Message-ID: <marc-lartc-105137225508638@msgid-missing> (raw)
In-Reply-To: <marc-lartc-105130762206276@msgid-missing>
[-- Attachment #1: Type: text/plain, Size: 2466 bytes --]
----- Original Message -----
From: "Jannes Faber" <jannes@elevate.nl>
To: "Stef Coene" <stef.coene@docum.org>; <pturley@rocksteady.com>;
<lartc@mailman.ds9a.nl>
Sent: Saturday, April 26, 2003 3:07 AM
Subject: Re: [LARTC] Testing traffic control
> I've been using TC and HTB for a while now (almost a year). Took a while
to
> get it running, but it's ok now (playing CounterStrike on one PC while two
> others are using DirectConnect and Emule are fully using the upstream and
> downstream).
>
> Anyway, until recently I was doing it all blind, using iptraf for some
rough
> indication of some total values, but that was about it. So I decided it
was
> time to make some graphs. So I made a simple perl script (ahum... actually
I
> ripped apart a script made by Stef and added my own stuff) using rrdtool
to
> store and display all the data.
>
> I attached it. You'll have to edit it a little for your own situation, but
> it's quite flexible. (I'm not a perl programmer, so expect some ugly C
> constructions).
>
> Basic commands:
>
> rrd_tc without parameters gives some help. But basically you call
> "rrd_tc.pl create" once to create a new database. Then you run "rrd_tc.pl
> collect" and keep it running in the background (nohup or in /etc/rc.local)
> to collect the actual data. Then you use "rrd_tc.pl graph xv stack
> update=10" to display a nice graph and have it updated every 10 seconds.
>
> This script stores and displays the counters for all the different TC
> classes as well as the total up and download from /proc/net/dev.
>
> Jannes Faber
>
> > On Friday 25 April 2003 23:57, Patrick Turley wrote:
> > > through each connection. Have the other computer display the rate at
> > > which data is being received for each connection in a really cool
> > > graphical way.
> > >
> > > Does anyone here actually have the tools to do this? I would be
terribly
> > > grateful if anyone could point me in the right direction.
> > Stef wrote:
> > I have some scripts. You can find them on www.docum.org. They don't
look
> > really cool, but they can show you what's going on in real-time.
> >
> > I have a script that uses iptables counters. An other uses the tc
> counters.
> > They are both shell scripts and I use them to automate my tests.
> >
> > I also have some scripts to store the tc counters in a rrd database so
you
> can
> > graph long term statistics. And I have written a java applet so you can
> see
> > real-time graphs.
> >
> > Stef
>
>
[-- Attachment #2: rrd_tc.pl --]
[-- Type: application/octet-stream, Size: 4407 bytes --]
#!/usr/bin/perl
# Default values (can also be set on the command line)
$arg{sleep} = "10" ; # seconds between readings
$arg{dev} = "eth0";
$arg{tc} = "tc-htb";
$arg{db} = "/var/local/tc.rrd";
$arg{file} = "/tmp/rrd_tc_graph.png";
$arg{time} = "1200";
$max=200000;
foreach my $arg (@ARGV) {
@split = split ( "=", $arg) ;
$arg{$split[0]} = ($split[1] eq "" ? 1 : $split[1]);
}
if ( $arg{create} ) {
system( "test -e $arg{db} && rm -i ". $arg{db});
system( "rrdtool create $arg{db} -s ". $arg{sleep}
. " DS:speed_up:COUNTER:60:U:$max"
. " DS:speed_dn:COUNTER:60:U:$max"
. " DS:speed_1_1:COUNTER:60:U:$max"
. " DS:speed_1_10:COUNTER:60:U:$max"
. " DS:speed_1_11:COUNTER:60:U:$max"
. " DS:speed_1_12:COUNTER:60:U:$max"
. " DS:speed_1_13:COUNTER:60:U:$max"
. " DS:speed_1_14:COUNTER:60:U:$max"
. " RRA:AVERAGE:0.5:1:" . (12 * 30)
. " RRA:AVERAGE:0.5:12:" . (60 * 2)
. " RRA:AVERAGE:0.5:120:" . (6 * 12)
. " RRA:AVERAGE:0.5:720:" . (24 * 7)
. " RRA:AVERAGE:0.5:". (720 * 24) .":". (365)
);
}
elsif ( $arg{graph} ) {
$type0 = ($arg{stack} ? "AREA" : "LINE3");
$type1 = ($arg{stack} ? "STACK" : "LINE2");
$type2 = ($arg{stack} ? "STACK" : "LINE1");
do {
system( "rrdtool graph ". $arg{file} . ($arg{update} eq "" ? "" : " -z ")
. " -s -$arg{time} -e -$arg{sleep} --step 5 -w 600 -h 300 -t \"Traffic ($arg{dev})\" -v \"byte/s\""
. ($arg{stack}
? ""
: " DEF:speed_1_1=$arg{db}:speed_1_1:AVERAGE AREA:speed_1_1#22ff22:\"1_1 (total)\""
)
. " DEF:speed_1_10=$arg{db}:speed_1_10:AVERAGE $type0:speed_1_10#aaaaaa:\"1_10 (cs)\""
. " DEF:speed_1_11=$arg{db}:speed_1_11:AVERAGE $type1:speed_1_11#000000:\"1_11 (ssh)\""
. " DEF:speed_1_12=$arg{db}:speed_1_12:AVERAGE $type1:speed_1_12#ff0000:\"1_12 (www)\""
. " DEF:speed_1_13=$arg{db}:speed_1_13:AVERAGE $type1:speed_1_13#66ffff:\"1_13 (ack)\""
. " DEF:speed_1_14=$arg{db}:speed_1_14:AVERAGE $type2:speed_1_14#0000aa:\"1_14 (rest)\""
. " DEF:speed_up=$arg{db}:speed_up:AVERAGE LINE1:speed_up#aa0000:\"Total UP\""
. " DEF:speed_dn=$arg{db}:speed_dn:AVERAGE"
. " CDEF:speed_dn10=speed_dn,10,/ LINE1:speed_dn10#00aa00:\"Total DOWN/10\""
. " > /dev/null"
);
if($arg{xv}) {
system("xv +nopos -dr 0 0 -poll ". $arg{file} ." &");
$arg{xv} = "";
}
sleep($arg{update});
} while($arg{update});
}
elsif ( $arg{collect} ) {
main () ;
}
else {
print " $0 create [sleep=SEC] [db=FILE]\n"
. " $0 collect [sleep=SEC] [db=FILE] [dev=DEV] [tc=FILE]\n"
. " $0 graph [xv] [stack] [time=SEC] [update=SEC] [file=FILE] [db=FILE]\n"
;
}
sub main {
format STDOUT_TOP =
Classid tokens ctokens bytes speed
------------------------------------------
.
format STDOUT =
@<<<<<<<< @<<<<<<<<@<<<<<< @<<<<< @<<<<<<<
$classid $tokens $ctokens $Sent $speed
.
while (1) {
my $flds="";
my $vals="";
my %acc = get_proccounters();
$flds .= "speed_up:speed_dn";
$vals .= "$acc{up}:$acc{dn}";
my %acc = get_counters () ;
foreach $key (keys(%acc)) {
$classid = $key;
$tokens = $acc{$key}{tokens} ;
$ctokens = $acc{$key}{ctokens} ;
$Sent{$key} = $acc{$key}{Sent} - $acc_vorige{$key}{Sent} ;
$Sent = $Sent{$key} ;
# write ;
$classid =~ s/:/_/;
$flds .= ($flds eq "" ? "" : ":") ."speed_". $classid;
$vals .= ($vals eq "" ? "" : ":") . $acc{$key}{Sent};
}
system("rrdtool update $arg{db} -t ". $flds ." N:". $vals );
sleep ($arg{sleep}) ;
} }
sub get_counters {
my %ACC ;
my @class = `$arg{tc} -s -d class show dev $arg{dev}` ; # Get all class info
foreach my $ele (@class) {
chomp ($ele) ;
my @temp = split(" ",$ele) ;
my $i = 0 ;
foreach my $temp (@temp) {
$i ++ ;
if ( $temp eq "htb" ) {
$classid = $temp[$i] ;
} elsif ( $temp =~ /\d/ ) {
#print "classid $classid $name $temp\n" ;
$ACC{$classid}{$name} = $temp ;
} else {
$temp =~ s/://g ;
$temp =~ s/\(//g ;
$name = $temp ;
}
}
}
return %ACC ;
}
sub get_proccounters {
my %ACC;
my @counters = `cat /proc/net/dev | grep $arg{dev}`;
my @temp = split(":",$counters[0]);
chomp($temp[1]);
my @temp = split(" ", $temp[1]);
$ACC{dn} = $temp[0];
$ACC{up} = $temp[8];
return %ACC;
}
next prev parent reply other threads:[~2003-04-26 15:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-25 21:57 [LARTC] Testing traffic control Patrick Turley
2003-04-25 22:51 ` Stef Coene
2003-04-26 7:53 ` Stef Coene
2003-04-26 15:52 ` sufcrusher [this message]
2003-05-10 12:41 ` Srikanth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-lartc-105137225508638@msgid-missing \
--to=sufcrusher@zonnet.nl \
--cc=lartc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.