[rrd-users] migrating MRTG data to rrdtool

Cyrille Bollu Cyrille.Bollu at fedasil.be
Fri Aug 22 16:44:57 CEST 2008


Hi,

Does anyone knows why, when converting MRTG logs to RRD, data are stored 
as integer???

(extract from MRTG_lib.pm. See last line)

while(<R>){
        chomp;
        ($next_time,$next{in},$next{out},$next{maxin},$next{maxout}) =
            split /\s+/;
        foreach my $s (@steps) {
            # bail if we have enough entries
            next if ref $store{in}{$s} and
                scalar @{$store{in}{$s}} > $sizes{$s};

            # ok we are still here. If next mark is before the next time
            # we take a short step, else we gobble up
            my $next_stop;
            do {
                if ($elapsed_time{$s} + $time - $next_time > $s) {
                    $next_stop = $mark{$s}-$s;
                } else {
                    $next_stop = $next_time;
                }
                my $time_diff = $time-$next_stop;
                foreach my $d (qw(in out)) {
                    $rate{$d}{$s} = ($rate{$d}{$s} * $elapsed_time{$s}
                                     + $cur{$d} * $time_diff) /
                               ($elapsed_time{$s} + $time_diff);
                }
                foreach my $d (qw(maxin maxout)){
                    $rate{$d}{$s} = $cur{$d} if $rate{$d}{$s} < $cur{$d};
                }

                $elapsed_time{$s} += $time_diff;
                if ($next_stop == $mark{$s}-$s) {
                   foreach my $t (qw(in out maxin maxout)){
                       $rate{$t}{$s}/=3600
                           if (defined 
$$rcfg{'options'}{'perhour'}{$router});
                       $rate{$t}{$s}/=60
                           if (defined 
$$rcfg{'options'}{'perminute'}{$router});
it's here --->                       push @{$store{$t}{$s}}, 
int($rate{$t}{$s});

I'm asking this because I'm monitoring a counter that increases by less 
than 1unit per second :-) (number of emails per second sent/received on a 
server).

With the "perhour" option in MRTG's config, the graph was still nice. But, 
when 0 is stored in the RRD I can't do anything anymore :-/

I'm thinking about just removing this casting but I wonder if there's some 
design/implementation issue that I don't understand...

So, does anyone knows?

Best regards,

Cyrille

(I know I should post this on the mrtg mailing-list. I'm in the process of 
(re-) subscribing to that list but I can't help asking. Sorry :-) )

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-users/attachments/20080822/1f7a8545/attachment-0001.html 


More information about the rrd-users mailing list