homesles:~ # grep rrd `which mrtg`
# log - logging of data via rateup or rrdtool
# postload rrdtool support
if ($cfg{logformat} eq 'rrdtool'){
if ($cfg{'logformat'} ne 'rrdtool') {
# undefined values are ok for rrdtool !
if (not ( $cfg->{ logformat } eq 'rrdtool'
my $dotrrd = "$$cfg{'logdir'}$$rcfg{'directory'}{$router}$router.rrd";
my $reallog = $$cfg{logformat} eq 'rrdtool' ? $dotrrd : $dotlog;
if ($$cfg{logformat} eq 'rrdtool') {
# maybe we can convert an .log file to the new rrd format
if (-e $dotlog and not -e $dotrrd) {
die "ERROR: RRDtool version 1.0.27 or later required to perform log2rrd conversion\n";
log2rrd($router,$cfg,$rcfg);
} elsif (! -e $dotrrd) {
debug('base',"create $dotrrd");
# create the rrd if it doesn't exist
my $rows = $$rcfg{'rrdrowcount'}{$router} || ( 4000 / $interval);
my @args = ($dotrrd, '-b', $time-10, '-s', int($interval * 60),
my @args = ($dotrrd, '-a', "ds0:$absi", '-a', "ds1:$abso",
# update the rrd
debug('log', "Calling: RRDs::update($dotrrd, '$time:$inlast:$outlast')");
RRDs::update("$dotrrd", "$time:$inlast:$outlast");
warn "ERROR: Cannot update $dotrrd with '$time:$inlast:$outlast' $e\n" if ($e);
# get the rrdtool-processed values back from rrdtool
my $lasttime = RRDs::last($dotrrd);
warn "ERROR: Cannot 'last' $dotrrd: $e\n" if ($e);
my $fetch = (RRDs::fetch($dotrrd,'AVERAGE','-s',$lasttime,'-e',$lasttime))[3];
warn "ERROR: Cannot 'fetch' $dotrrd: $e\n" if ($e);
debug('log', "Called: RRDs::fetch($dotrrd,'AVERAGE','-s',$lasttime,'-e',$lasttime)");
########## rrdtool users have left here ###############
if ( not defined $$cfg{nomib2} and $$cfg{logformat} ne 'rrdtool' ) {
# for folks using rrdtool I am allowing numbers