[mrtg] Include vs require

McDonald, Dan Dan.McDonald at austinenergy.com
Wed Oct 8 02:30:16 CEST 2008


On Wed, 2008-10-08 at 12:37 +1300, Steve Shipway wrote:

> For backwards compatibility, should Include: still create a fail on
> not found, and a new directive created for non-required include?  Such
> as:
> 
> Include-optional: filename.cfg
> 
> Or, maybe it would be better to add a second parameter to the existing include statement:
> 
> #(This is a required include)
> Include: filename.cfg
> #(This is an optional include)
> Include: filename.cfg optional
> 
> I think I prefer the second way for backwards compatibility, although
> it depends on how MRTG currently parses the file.

Either way is going to break if you run on an older version.  The
current regex will fail to match if there is a second parameter after
the included file name.

        if (/^include:\s*(.*?\S)\s*$/i){
                push @filestack, $file;
                push @handstack, $hand;
                $nextfile = $1;
                local *FH;
                open (FH, $nextfile)
                 || open (FH, ($cfgfile =~ m#(.+)${MRTG_lib::SL}[^${MRTG_lib::SL}]+$#)[0] . ${MRTG_lib::SL} . $nextfile)
                 || do { die "ERROR: unable to open include file: $nextfile\n"};
                $hand = *FH;
                next;
        }

-- 
Daniel J McDonald, CCIE #2495, CISSP #78281, CNX
Austin Energy
http://www.austinenergy.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.oetiker.ch/pipermail/mrtg/attachments/20081007/b87061a5/attachment.bin 


More information about the mrtg mailing list