Re: tc & rrd question

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Basicaly it is easy to use rrd tool, the hardest part for me was to setup
rrd database correctly
here is example

RRDs::create("$rrd","-s",$period,
"DS:TR:GAUGE:300:0:U",
"RRA:AVERAGE:0.5:1:1440",                  #  0.5- uaualy leave as is : 1-
for first entry use 1  :1440 number of points
"RRA:AVERAGE:0.5:15:3072");                #: 0.5: 15 needs 15 updates to
create one average database entry  :3072


Complete example for perl, probably will be good for you too. have
resolution of 1 min for 1 day and 15 min resolution for 1 month. uopdates
should be done each minute
$time=time;
$rrd="./data/$ip.rrd";  #$rrd is filename
    if (!(-e "$rrd")) { print "creating $rrd\n";
       RRDs::create("$rrd","-s",$period,
        "DS:TR:GAUGE:300:0:U",
        "RRA:AVERAGE:0.5:1:1440",
        "RRA:AVERAGE:0.5:15:3072");
      if (my $error=RRDs::error()) {print "Cannot create $rrd: $error\n";}
    }

    RRDs::update("$rrd","$time:$tr");   # $tr is the data you want to add to
database

 if (my $error=RRDs::error()) {print "Cannot update $rrd: $error\n";}

}
##################
example for view script. shows load graph and total traffic per $period
$period is in seconds

$period=3600*24; #(for one day)

$start=time-$period; #starts from current time.
  $rrd="./data/$ip.rrd";
    RRDs::graph ("$cache/$name.png","--start=$start","--width=720",
  "DEF:d=$rrd:TR:AVERAGE",
  "CDEF:down=d,UN,0,d,IF,$period,*",
  "LINE1:d#6600cc",
  "GPRINT:down:AVERAGE:%1.1lf%sB Download",
  );

    if (my $error=RRDs::error()) {print "Cannot graph $rrd: $error\n";}

    print "<img src=\"$cache/$name.png\"> \n";
    print "$name $ip<br>\n";
  }








----- Original Message ----- 
From: <adi@xxxxxxxxxx>
To: <lartc@xxxxxxxxxxxxxxx>
Sent: Friday, July 30, 2004 12:21 PM
Subject:  tc &amp; rrd question


> hello list,
> i've got a small question related to tc and rrd.
>
> my problem is as follows. i've written a small c app that takes the stats
> of tc using libs from iproute2 package and outputs a shell script that
> updates rrd files (2 ds: 1 gauge for speed, 1 counter for sent). i've
> followed the manuals from tobi's website on how to create and update the
> database. the dump is quite curious even after a hole day of updating
> (every 5 min).
>
> can anyone here share his/hers experience with these tools. any links or
> resources maybe even some example code are very welcome.
>
> thanks
> _______________________________________________
> LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
> http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
>

_______________________________________________
LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux