Ad Widget

Collapse

Linux Traffic Shaping Graphs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • innovot
    Junior Member
    • Nov 2013
    • 15

    #1

    Linux Traffic Shaping Graphs

    Would like to start capturing statistics from 'tc' so we can see how our QoS is performing. Thoughts on the best way to do this ? Am guessing that we would write a script on the node to run the commands via Zabbix Agent and pass that data back to the server as items ? Thank you.
  • JeromeB
    Junior Member
    • Nov 2014
    • 5

    #2
    TC traffic stats

    Here's what I did to gather and graph stats from a bunch of htb classes that are defined in an IMQ interface on couple our our linux based (vyatta) routers.

    First I made a script to run a LLD proccess for traffic classes, it takes an argument which is the device I'm trying to discover traffic stats from:

    Code:
    #! /usr/bin/perl
    $first = 1;
    $ind = 0;
    print "{\n";
    print "\t\"data\":[\n\n";
    
    my @data = qx/\/sbin\/tc class show dev $ARGV[0]/;
    foreach (@data)
            {
            ($index) = (@data[$ind] =~ /class\s\S+\s(\S+)\s.+/);
            ($type) = (@data[$ind] =~ /class\s(\S+)\s\S+\s.+/);
            print " ,\n" if not $first;
            $first = 0;
            print "\t{ ";
            print "  \"{#CLASSINDEX}\":\"$index\",";
            print "    \"{#CLASSTYPE}\":\"$type\"";
            print "\t}";
            $ind = $ind+1;
            }
    print "\n\t]\n";
    print "}\n";
    Then a second script to populate the discovered class items, the arguments on this one are the device, the tc class index, and the item:

    Code:
    #! /usr/bin/perl
    my @data = qx/\/sbin\/tc -s class show dev $ARGV[0]|grep $ARGV[1] -A 2/;
    if ($ARGV[2] eq ifOutOctet)     {
            ($output) = (@data[1] =~ /.+Sent\s+(\d+)\s.+/);
            }
    elsif ($ARGV[2] eq ifOutPkt)    {
            ($output) = (@data[1] =~ /.+bytes\s+(\d+)\s.+/);
            }
    elsif ($ARGV[2] eq dropped)     {
            ($output) = (@data[1] =~ /.+dropped\s+(\d+),.+/);
            }
    elsif ($ARGV[2] eq backlog)     {
            ($output) = (@data[2] =~ /.+backlog\s+\d+b\s(\d+)p.+/);
            }
    elsif ($ARGV[2] eq capacity)    {
            ($current) = (@data[2] =~ /.+rate\s+(\d+)Kbit.+/);
            ($denom) = (@data[0] =~ /.+ceil\s+(\d+)Kbit.+/);
            ($output) = $current/$denom;
            }
    print "$output\n"
    those scripts I installed onto the target system (in my case the vyatta routers), and created UserParameters to call my scripts from the zabbix agent:

    Code:
    ### Option: UserParameter: TC discovery
    UserParameter=net.tc.class.discovery[*],/config/scripts/tc_class_discovery.pl $1
    
    ### Option: UserParameter: TC Stats
    UserParameter=net.tc.stats[*],/config/scripts/tc_stats.pl $1 $2 $3
    Then I setup a LLD rule using the net.tc.class.discovery[tc_device] key,
    Click image for larger version

Name:	Screenshot_2015-05-11_11-38-23.png
Views:	1
Size:	23.2 KB
ID:	312993

    and filters to only match against the leaf htb classes
    Click image for larger version

Name:	Screenshot_2015-05-11_11-39-03.jpg
Views:	1
Size:	14.5 KB
ID:	312994

    Setup the discovery items ame way using the UserParameter
    Click image for larger version

Name:	Screenshot_2015-05-11_11-40-01.jpg
Views:	1
Size:	16.1 KB
ID:	312995

    Made a graph template
    Click image for larger version

Name:	Screenshot_2015-05-11_11-40-42.jpg
Views:	1
Size:	35.2 KB
ID:	312996

    and Voila
    Click image for larger version

Name:	Screenshot_2015-05-11_11-43-03.jpg
Views:	1
Size:	31.1 KB
ID:	312997

    Comment

    Working...