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.
Ad Widget
Collapse
Linux Traffic Shaping Graphs
Collapse
X
-
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:
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 $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";
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:#! /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"
Then I setup a LLD rule using the net.tc.class.discovery[tc_device] key,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
and filters to only match against the leaf htb classes
Setup the discovery items ame way using the UserParameter
Made a graph template
and Voila
Comment