[mrtg] Re: UseRRDTool and MaxBytes does not work ??
Rainer Bawidamann
lists at ripper.informatik.uni-ulm.de
Fri Feb 25 13:37:42 MET 2000
In article <38B4FC51.BC24C5A at linuxnet.ch> you wrote:
> I did a patch for the actual mrtg that each time it updates the rrds it
> will take the maxbytes and put it in the ds0 max and the ds1 max value.
>
> If aomeone is interested I can put this patch online. (Just two lines of
> rrdtool tune...)
I didn't implemented this yet as of the time penalty. I looked at the code,
the costs are:
- the exec call of course
- one read (~ 4096 bytes, it uses buffered fread)
- one write (352 byes for a rrd with 2 ds)
(use of mmap could improve this ...)
I made a patch witch corrects another problem as well. It sets the maximum
and minimum at creation time and reset the maximum at every update. The
rrdupdate after the rrdtune should minimize the costs. The other problem was
that the automatic rrd creation failed if interval was not set.
The patch is only 54 lines so I include it here.
Bye ... Rainer
Rainer.Bawidamann at informatik.uni-ulm.de
--snip--
diff -urN mrtg-2.8.12/run/mrtg mrtg-2.8.12.rb/run/mrtg
--- mrtg-2.8.12/run/mrtg Sun Feb 6 00:56:30 2000
+++ mrtg-2.8.12.rb/run/mrtg Fri Feb 25 12:06:00 2000
@@ -944,7 +944,7 @@
($uptime,$name) = &snmpget(
$$rcfg{"community"}{$rou}."@".$$rcfg{"router"}{$rou},
'sysUptime',
- 'sysName');
+ 'sysName'); #"
}
($inlast, $outlast, $uptime, $name, $time);
@@ -986,13 +986,19 @@
$up_abs = $dstype{$up_abs};
# update the database.
my $rrd = "$$cfg{'workdir'}${main::SL}$$rcfg{'directory'}{$router}${main::SL}$router.rrd";
+ # set minimum/maximum values. use 'U' if we cannot get good values
+ # the lower bound is hardcoded to 0
+ my $absi = int($$rcfg{'absmax'}{$router} ? $absmax : $maxvi) or 'U';
+ my $abso = int($$rcfg{'absmax'}{$router} ? $absmax : $maxvo) or 'U';
if (! -e $rrd) {
# create the rrd if it doesn't exist
my $now = time;
- $now = int($now / ($$cfg{interval} * 60) ) * ($$cfg{interval} * 60);
- RRDs::create($rrd, '-b', $now, '-s', int($$cfg{interval} * 60),
- "DS:ds0:$up_abs:600:U:U",
- "DS:ds1:$up_abs:600:U:U",
+ # don't fail if interval is not set
+ my $interval = $$cfg{interval} or 5;
+ $now = int($now / ($interval * 60) ) * ($interval * 60);
+ RRDs::create($rrd, '-b', $now, '-s', int($interval * 60),
+ "DS:ds0:$up_abs:600:0:$absi",
+ "DS:ds1:$up_abs:600:0:$abso",
"RRA:AVERAGE:0.5:1:600",
"RRA:AVERAGE:0.5:6:700",
"RRA:AVERAGE:0.5:24:775",
@@ -1003,11 +1009,16 @@
"RRA:MAX:0.5:288:797");
my $e = $RRDs::error;
die "Cannot create logfile: $e\n" if $e;
+ } else {
+ # update the minimum/maximum according to maxbytes/absmax
+ # cost: 1 read/write cycle, but update will reuse the buffered data
+ RRDs::tune($rrd, '-a', "ds0:$absi", '-a', "ds1:$abso");
}
# update the rrd
RRDs::update("$rrd", "$time:$inlast:$outlast");
my $e = $RRDs::error;
- die "Cannot update logfile: $e" if ($e);
+ # only warn on error, other targets might work
+ warn "Cannot update logfile: $e" if ($e);
# the html pages and the graphics are created at "call time" so that's it!
# (the returned hashes are empty, it's just to minimize the changes to mrtg)
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:mrtg-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/mrtg
More information about the mrtg
mailing list