# aptitude install rrdtool
And launch the script. It will create a file called **tcgraph.rrd** that we need to store into **/var/www/tcgraph/**.
===== tcparsestat.pl: Get the statistics =====
Given our policy, the TC output will look like this :
# tc -s class show dev eth0
class htb 1:99 parent 1:1 leaf 199: prio 7 rate 109000bit ceil 768000bit burst 2Kb cburst 1983b
Sent 2275664 bytes 1821 pkt (dropped 0, overlimits 0 requeues 0)
rate 26320bit 2pps backlog 0b 0p requeues 0
lended: 1306 borrowed: 515 giants: 0
tokens: 137986 ctokens: 19369
class htb 1:1 root rate 768000bit ceil 768000bit burst 1983b cburst 1983b
Sent 8947521 bytes 7293 pkt (dropped 0, overlimits 0 requeues 0)
rate 164248bit 16pps bac
[....]
So, to get the bandwidth usage of each class, we need to parse the "Sent" value of each class.
This can be done with Perl using the following script.
# aptitude install librrds-perl libproc-daemon-perl
And launch it from the command line. You can check the parsed values from the log file **/var/www/tcgraph/tcgraph.log**.
# /usr/bin/tcparsestat.pl
# tail -f /var/www/tcgraph/tcgraph.log
1271339880:326104:3585984:2871760:87736:603777088:0:36184008
Good to go.
# sh buildtcgraph.sh current.png -3600
797x244
creates a file called current.png that contain the statistics for the last hour.
TCgraph v.$VERSION by Julien Vehent | and Mailgraph |