[mrtg] New MRTG install... Run as Daemon and RRD setup?

Jan Ferré Jan.Ferre at uni-c.dk
Fri Oct 1 15:53:34 CEST 2010

Arvon Griffiths wrote:
> On my currently working (but old) mrtg set up, I have made sub-directories and put all of my cfg files in those.  Then I use a bash script to run mrtg against all of the cfg files in the dir.  I also have cron to to 'run' sets of these directories each minute (to spread them out).
> I read the http://www.steveshipway.org/forum/viewtopic.php?f=2&t=4093 and for clarification-
> Is there a way to run mrtg in daemon mode and use a wildcard in the master.cfg with Include: ?  I ask this because it really convenient just to be able to drop a cfg file in a dir and have mrtg run it WITHOUT having to also edit the master.cfg.  If not, is there a way to do this in daemon mode?

We use the crontab/script way too. The script however forges into
multiple instances:

#!/usr/bin/perl -w

use Carp;
use strict;

my $BASE = shift;
my $PROGRAM='/usr/local/mrtg-2/bin/mrtg';

sub run
  my (@cmd) = @_;
#  print STDERR "$$: run(@cmd)\n";
  exec @cmd;
#  print STDERR "$$: done.\n";

sub detach
  unless (fork)
    unless (fork)
      sleep 1 until getppid == 1;
      my $func = shift;
    exit 0;

opendir DIR, $BASE or confess "opendir: $!";

while (defined($_ = readdir DIR))
  next if /^\./ or ! /\.cnf$/;
  my $f = $_;
  detach(\&run, $PROGRAM, "$BASE/$f");
  sleep 7;

closedir DIR or confess "closedir: $!";

This script is called every 5 minutes from crontab by:
nice -n 10 /home/unimogul/bin/full_mrtg.v2 \
  /home/unimogul/netdrift/Systemer/etc/MRTG \
  >/home/unimogul/netlog/lastMRTG.log 2>&

The MRTG-directory contains 53 uneven config-files with a total of 1411

Jan Ferré

Jan Ferré - UNI-C Netdrift - DTU Bygning 304, DK-2800 Lyngby
tlf. +45 3587 8935, cell. +45 2160 8012, fax. +45 3587 8990
EAN-no.: 5798000555198

More information about the mrtg mailing list