[rrd-users] Re: Help a new and slightly lost user! :(

Michael Thompson mike at thompsonmike.co.uk
Sun Nov 14 20:40:02 MET 2004


On Sunday 14 November 2004 19:20, Alex van den Bogaerdt wrote:
> On Sat, Nov 13, 2004 at 10:20:09AM +0000, Michael Thompson wrote:
> > Sorry, I just read that message and realised it does not make any sense!
>
> Indeed,  "it does not work" is a bit too vague
>
> > What is happening is that it is logging data, but it is logging the
> > verticle scale as k, it needs to show the difference in packets between
> > each reading, and not have any m k or any other symbols apart from the
> > amounts.
>
> You already understand GAUGE may not be the best counter type.

Umm, I have used Counter and DERIVE, yet it still dos'nt get the data right.
>
> The difference between each reading is not something you want to
> use rrdtool for.  For these kind of applications you should choose
> sql, access, or even a flat file.
>
Is that not what DERIVE Should do?

> If you want to see a rate, an amount of rejects per second, then rrdtool
> is the tool to use.

That is exactly what I am trying to do, but accuracy is important.
>
> RTFM rrdgraph, stuff about units-exponent

I have RTFM, and the units-exponent is'nt helping. It is the accuracy that I 
need help with. 


I have the following Perl Script 
 
 

Code:



 #!/usr/bin/perl 
 use RRDs; 
 
 # define location of rrdtool databases 
 my $rrd = '/var/lib/rrd'; 
 # define location of images 
 my $img = '/var/www/localhost/htdocs/temp/'; 
 
 &ProcessChain("DROP-INPUT", "Input Chain Drops"); 
 &ProcessChain("DROP-FORWARD","Forward Chain Drops"); 
 
 sub ProcessChain 
 { 
 # process interface 
 # inputs: $_[0]: Chain Name 
 #         $_[1]: Chain Description 
 
         # get info 
         my $in = `/sbin/iptables -L $_[0] -v | grep LOG | awk '{print \$1}'`; 
         #my $out =`/sbin/iptables -L $_[0] -v | grep LOG | awk '{print 
\$2}'`; 
 
         # remove eol chars 
         chomp($in); 
 
         print "$_[0] packets in: $in\n"; 
 
         # if rrdtool database doesn't exist, create it 
         if (! -e "$rrd/$_[0].rrd") 
         { 
                 print "creating rrd database for $_[0]...\n"; 
                 RRDs::create "$rrd/$_[0].rrd", 
                         "-s 300", 
                         "DS:drop:DERIVE:600:0:12500000", 
                         "RRA:AVERAGE:0.5:1:576", 
                         "RRA:AVERAGE:0.5:6:672", 
                         "RRA:AVERAGE:0.5:24:732", 
                         "RRA:AVERAGE:0.5:144:1460"; 
         } 
 
         # insert values into rrd 
         RRDs::update "$rrd/$_[0].rrd", 
                 "-t", "drop", 
                 "N:$in"; 
 
         # create traffic graphs 
         &CreateGraph($_[0], "day", $_[1]); 
         &CreateGraph($_[0], "week", $_[1]); 
         &CreateGraph($_[0], "month", $_[1]); 
         &CreateGraph($_[0], "year", $_[1]); 
 } 
 
 sub CreateGraph 
 { 
 # creates graph 
 # inputs: $_[0]: Chain Name 
 #         $_[1]: interval (ie, day, week, month, year) 
 #         $_[2]: Chain Description 
 
         RRDs::graph "$img/$_[0]-$_[1].png", 
                 "-s -1$_[1]", 
                 "-t $_[0] :: $_[2]", 
 #               "--lazy", 
                 "-h", "80", "-w", "600", 
                 "-l 0", 
                 "-a", "PNG", 
                 "-v Packets", 
                 "DEF:drop=$rrd/$_[0].rrd:drop:AVERAGE", 
                 "CDEF:dropav=drop,3600,*", 
                 "AREA:dropav#32CD32:Dropped Packets", 
                 "LINE1:dropav#336600", 
                 "GPRINT:dropav:MAX:  Max\\: %5.0lf %s", 
                 "GPRINT:dropav:AVERAGE: Avg\\: %5.1lf %S", 
                 "GPRINT:dropav:LAST: Current\\: %5.0lf %SPackets", 
                 "HRULE:0#000000"; 
         if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] 
traffic graph: $ERR$ 
 } 
 
 


 
 Now this _does_ work, with one problem, the values are all wrong. 
 
 The graph looks like this 
 
 http://mains.bounceme.net/DROP-INPUT-day.png 
 
 
 As you can see, the current value is 12, however the command returns 
 4. So where is it getting the value of 12? 
 
 Could it be the fact that I am storing the Average value in the RRD? I have 
several other scripts that are virtually the same and they all return the 
correct values. 

>
> HTH
> Alex

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list