* [LARTC] Questions about qdisc statistics
2004-10-25 2:05 [LARTC] Questions about qdisc statistics ngo giang
@ 2004-10-25 8:26 ` Antonios Chalkiopoulos
2004-10-25 10:40 ` Ramasubramaniyan Srinivasan
1 sibling, 0 replies; 3+ messages in thread
From: Antonios Chalkiopoulos @ 2004-10-25 8:26 UTC (permalink / raw)
To: lartc
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
>Can I use round robin database and mrtg tool to generate html files at linux
>routers and call them from windows PC ?
>If it is impossible , can I use snmp to retrieve data from linux router at
>windows PC (snmp server at linux and snmp client at windows , if i don't
>misunderstand ) and use round robin database and mrtg tool to generate html
>pages at windows ?
You can do both although i haven't managed to compile succesfully the QoS snmp
extensions with net-snmp although lots of people have been succesfull at
that.
As far as round robin databases and mrtg (rrdtool is even better than mrtg)
here is a script to help you. Just run:
php tc.phps <-- In your linux QoS router, and
cp graph.php /srv/www/htdocs/ <-- In the apache htdocs of your linux QoS
router
[-- Attachment #2: graph.php --]
[-- Type: application/x-php, Size: 2139 bytes --]
[-- Attachment #3: tc.phps --]
[-- Type: text/x-c++src, Size: 6718 bytes --]
#
# Version 0.01 - 20 Sept 2004
# Version 0.02 - 20 Sept 2004 - 17:21
# Version 0.03 - 22 Sept 2004 - 18:03 --> classes & qdiscs work perfectly
# Version 0.04 - 23 Sept 2004 - 16:00 --> Added checks for tc , rrdtool
# Version 0.05 - 30 Sept 2004 - 12:12 --> GRED virtual channels are properly parsed.
<?
#Variables
$DEV=eth0;
$TC="/usr/sbin/tc";
$qdisc;
$counter=1;
set_time_limit(0);
checkTools();
createFiles("$TC qdisc ls dev $DEV");
createFiles("$TC -s class show dev $DEV");
sleep(3);
for($ct=0;$ct<3600;$ct++)
{
$counter =1;
updateRRD("$TC -s qdisc ls dev $DEV");
updateRRD("$TC -s class show dev $DEV");
sleep(2);
}
################ FUNTION check_availability_of_tools(); ################
function checkTools()
{
exec("which tc",$tc_tool);
if (!file_exists($tc_tool[0]))
{
echo "\n\n\n\n";
echo "iproute2 is not installed or not in the path.\n";
echo "Download from http://developer.osdl.org/dev/iproute2/ \n";
echo "\n\n\n\n";
exit ("iproute2 not installed in this computer\n");
}
exec("which rrdtool",$rrd_tool);
if (!file_exists($rrd_tool[0]))
{
echo "\n\n\n\n";
echo "Download and install rrdtool from \n";
echo "http://people.ee.ethz.ch/~oetiker/webtools/rrdtool//index.html \n";
echo "\n\n\n\n";
exit ("rrdtool not installed in this computer\n");
}
} ## end function
####################### FUNTION createFiles(); #########################
function createFiles($tc_command)
{
global $qdisc;
global $counter;
# 1. Execute tc command and store all output lines to --> $tc_lines
exec($tc_command,$tc_lines);
# 2. Go through every line of the tc output
for($i=0;$i<count($tc_lines);$i++)
{
# 3. If line is not empty, continue...
if($tc_lines[$i]!="")
{
$line=preg_split("/[\s,]+/",$tc_lines[$i]);
# 4. If first token each line contains 'DP:' it is a GRED virtual channel
if ( strstr($line[1],"DP:") ) {
$filename=$line[1];
$filename=ereg_replace(":", "_", $filename);
echo "Filename at $counter is $filename\n";
$qdisc[$counter]=$filename;
$counter++;
if (!file_exists("$filename.rrd")) {
echo "Creating new file ... ... $filename.rrd\n";
passthru("rrdtool create $filename.rrd --step 2 DS:bytes:COUNTER:600:U:U RRA:AVERAGE:0.5:1:1200 DS:packets:COUNTER:600:U:U RRA:AVERAGE:0.5:1:1200 DS:dropped:COUNTER:600:U:U RRA:AVERAGE:0.5:1:1200");
}
}
# 5. If first token of each line contains 'qdisc' or 'class' it is something of interest
if ( ($line[0] == "qdisc") || ($line[0] == "class") ) {
$filename=$line[1] . "." . $line[2];
$filename=ereg_replace(":", "_", $filename);
echo "Filename at $counter is $filename\n";
$qdisc[$counter]=$filename;
$counter++;
if (!file_exists("$filename.rrd")) {
echo "Creating new file ... ... $filename.rrd\n";
passthru("rrdtool create $filename.rrd --step 2 DS:bytes:COUNTER:600:U:U RRA:AVERAGE:0.5:1:1200 DS:packets:COUNTER:600:U:U RRA:AVERAGE:0.5:1:1200 DS:dropped:COUNTER:600:U:U RRA:AVERAGE:0.5:1:1200");
}
}
}
}
} ## end of function
####################### FUNCTION updateRRD(); ##########################
function updateRRD($tc_command)
{
global $qdisc;
global $counter;
$dp_counter=0;
# 1. Execute tc command and store all output lines to --> $tc_lines
$tc_lines=null;
exec($tc_command,$tc_lines);
# 2. Go through every line of the tc output
for($i=0;$i<count($tc_lines);$i++)
{
# 3. If line is not empty, continue...
if($tc_lines[$i]!="")
{
# 4. If a line contains the word 'bytes' it is interesting one!
if (preg_match("/(bytes)/",$tc_lines[$i]) )
{
# 5. Split tc_line to line tokens
$token=preg_split("/[\s,]+/",$tc_lines[$i]);
# 6. If line contains word 'eqma' be careful because it is definetly a GRED virtual queue
# example :
#
# qdisc gred 8066:
# DP:1 (prio 8) Average Queue 0b Measured Queue 0b
# Packet drops: 0 (forced 0 early 0)
# Packet totals: 6787 (bytes 734738) ewma 3 Plog 25 Scell_log 12
# DP:2 (prio 8) Average Queue 0b Measured Queue 0b
# Packet drops: 0 (forced 0 early 0)
# Packet totals: 0 (bytes 0) ewma 3 Plog 22 Scell_log 12
#
# To extract filename, look at first token of line tc_lines at i-2
if (preg_match("/(ewma)/",$tc_lines[$i]) )
{
$dp_counter++;
$counter++;
$filename=$qdisc[$counter].".rrd";
#echo " For filename= $filename total_packets $token[3] ... bytes_total $token[5]\n";
#echo " 1--> $token[1] 2--> $token[2] 3--> $token[3] 4--> $token[4] 5--> $token[5] \n";
#1--> Packet 2--> totals: 3--> 0 4--> (bytes 5--> 0)
$pkts=$token[3];
# remove unwanted ')' at the end of the string
$temp=strrchr($token[5], ")");
$sent=substr($token[5],0, -strlen($temp));
# RED - GRED packets!!
$red_line=$tc_lines[$i-1];
$red_token=preg_split("/[\s,]+/",$red_line);
echo "For filename = $filename we have packets dropped: $red_token[3] . $red_token[5] where dropped and $red_token[7] were early dropped\n";
$drops=1; #to-do: to count drops look at line @ i-1 token 3
passthru("rrdtool update $filename N:$sent:$pkts:$drops");
echo("rrdtool update $filename N:$sent:$pkts:$drops\n");
} else
{
$sent=$token[2];
$pkts=$token[4];
$drops=$token[7];
if ( $dp_counter != 0 ) {
$filename=$qdisc[$counter-$dp_counter].".rrd";
$dp_counter=0;
} else
{
$filename=$qdisc[$counter].".rrd";
}
passthru("rrdtool update $filename N:$sent:$pkts:$drops");
echo "passthru rrdtool update $filename N:$sent:$pkts:$drops\n";
$counter++;
}
}
}
}
} ## end function
?>
# qdisc gred 805f:
# DP:1 (prio 8) Average Queue 0b Measured Queue 0b
# Packet drops: 0 (forced 0 early 0)
# Packet totals: 0 (bytes 0) ewma 3 Plog 25 Scell_log 12
# DP:2 (prio 8) Average Queue 0b Measured Queue 0b
# Packet drops: 0 (forced 0 early 0)
# Packet totals: 0 (bytes 0) ewma 3 Plog 22 Scell_log 12
# DP:3 (prio 8) Average Queue 36110b Measured Queue 35428b
# Packet drops: 517 (forced 0 early 517)
# Packet totals: 14128 (bytes 14721376) ewma 3 Plog 20 Scell_log 12
# Sent 14182662 bytes 13611 pkts (dropped 517, overlimits 517 requeues 0)
# backlog 35428b 34p
#qdisc red 4: limit 600000b min 30000b max 60000b
# Sent 5285024 bytes 5072 pkts (dropped 42031, overlimits 42031 requeues 0)
# backlog 63562b 61p
# marked 0 early 42031 pdrop 0 other 0
#qdisc htb 3: r2q 10 default 12 direct_packets_stat 68
# Sent 44076642 bytes 42301 pkts (dropped 42548, overlimits 89997 requeues 0)
# backlog 1043p
#qdisc dsmark 1: indices 0x0040 set_tc_index
# Sent 44083936 bytes 42308 pkts (dropped 42548, overlimits 0 requeues 0)
# backlog 1043p
^ permalink raw reply [flat|nested] 3+ messages in thread