[mrtg] CfgMaker: Target Naming Convention?
Daniel J McDonald
dan.mcdonald at austinenergy.com
Wed Nov 14 14:01:48 CET 2007
On Tue, 2007-11-13 at 16:17 -0500, Dan Mahoney, System Admin wrote:
> On Thu, 8 Nov 2007, Daniel J McDonald wrote:
>
> >
> > On Thu, 2007-11-08 at 16:46 -0500, Dan Mahoney, System Admin wrote:
> >> Hey all,
> >>
> >> We would like to create entries like this with cfgmaker:
> >>
> >> Target[a-1-1]: 1:public at 192.168.1.66:
> >
> >> I suppose I could do this with something complex like the --if-template
> >> option, but wouldn't it be easier to just have cfgmaker have a
> >> --target-name="a-1" option?
> >
> > No, using if-templates would be by far the easiest way to deal with
> > this.
>
> I just spent an hour looking at the cfgmaker code. The easiest way to
> patch this felt like adding a dummy SNMP option for the router, which
> would be substituted for the target name (other options, like cfgmaker
> (myrouter-)community at router might have also worked, with minimal twiddling
> to getopt. The problem is, I feel my changes wouldn't be accepted, as
> they're non-standard, and I'd lose them if I upgrade, and my goal is to
> try to do this with as many standard tools as possible (otherwise I'd just
> generate configs without cfgmaker).
How about something like (note, not tested)
1. You create a text file that lists real hosts and the changes. Call
it xlate.conf. Perhaps even regexes... like:
1.2.3.4_ A-4-
1.2.3.5_ A-9-
1.2.3.([368])_ B-$1-
then, in the top of your iftemplate:
if ($is_ok) {
open REGEX xlate.conf;
while (my $reg = <REGEX>) {
my @reg = split(/\t/,$reg);
my $first = qr/$reg[0]/;
my $second = qr/$reg[1]/;
next unless $target_name =~ $first;
$target_name =~ s/$first/$second/;
last;
};
close REGEX;
$target_lines = <<NEWNAME
Target[$target_name]: $if_ref:$router_connect
MaxBytes[$target_name]: $if_speed
Options[$target_name]: bits
WithPeak[$target_name]: wmy
Title[$target_name]: $html_if_snmp_name - $html_if_snmp_alias
PageTop[$target_name]: <H1>$html_if_snmp_alias - Traffic </H1>
NEWNAME
;
} else {
$head_lines="";
$problem_lines="";
$target_lines="";
$separator_lines="";
}
Naturally, you can add whatever directives you would like to the
iftemplate. I normally add bbmrtg.pl and routers2.cgi directives, which
is why I started down the road of building iftemplates...
--
Daniel J McDonald, CCIE #2495, CISSP #78281, CNX
Austin Energy
http://www.austinenergy.com
More information about the mrtg
mailing list