[mrtg] CfgMaker: Target Naming Convention?
Dan Mahoney, System Admin
danm at prime.gushi.org
Tue Nov 13 22:17:06 CET 2007
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).
I've just also spent two hours trying to figure out if-templates. On top
of the fact that there's no way (I can tell) to pass arguments to the
template code easily (as unknown options are discarded by getopt::long...)
..and the fact that (again, near as I can tell) there's no way to make
this smart enough to just accept perl code on the command line for
templates, but instead put them in a file (as filters are)...
It looks like every router I would want to generate would have to have its
own filter line (and I'm already looking to do this from a script,
otherwise I'd just hand-edit the things).
the easiest way to do this would be as follows:
cfgmaker public at 1.2.3.4 | sed -e 's/\[1.2.3.4_/[A-4-/g' >file.cfg
Yeah, it breaks --outfile
An alternative (if we're inisitent on being able to work with
user-supplied code) might be a "postgenerate command" to pass the ENTIRE
config file through before doing a final write (where I could specify a
similar regex.)
Tobi, or anyone else, if you can figure out an easy way to do this (again,
from the command line, I may have to do this for hundreds of hosts) I'll
buy you a wishlist thing, send you a bauble via paypal, or whatever.
The above solution works, but "feels dirty". Then again, so does using
experimental, subject-to-change code, so I'm not sure which is the lesser
of two evils there.
-Dan
--
"I hate Windows"
-Tigerwolf, Anthrocon 2004
--------Dan Mahoney--------
Techie, Sysadmin, WebGeek
Gushi on efnet/undernet IRC
ICQ: 13735144 AIM: LarpGM
Site: http://www.gushi.org
---------------------------
More information about the mrtg
mailing list