ccie has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
my first post, so have mercy please ;-)
Goal: compare the configuration template (I call it MASK) against actual device configurations to detect anomalies.
Here's a sample device config:
And now my template/MASK:============== mpls ldp router-id 192.168.130.5 nsr graceful-restart backoff 5 10 session protection neighbor 192.168.130.1 password encrypted pwd1 neighbor 192.168.130.2 password encrypted pwd2 neighbor 192.168.130.25 password encrypted pwd3 igp sync delay 10 label allocate for LLAF ! log neighbor nsr ! interface TenGigE0/0/0/0 ! interface TenGigE0/1/0/0 ! interface TenGigE0/7/0/0 ! ! ==============
So I read all device config in a string and match with /..../s against template above; before actual match the template updated with $mask_tmp =~ s/__REGEX__/^\\n+/g; Easy part is to match the template against the configuration when eg. number of neighbor or interface statements is the same on all devices. But that is not the case, so I'm looking for idea how to match (and capture necessary parameters such as IP numbers of all neighbors) irrespective of number of neighbors/interfaces in actual config. TIA====================================================================== =|MASK|mpls ldp|= ====================================================================== (mpls ldp) (router-id) (__REGEX__) nsr graceful-restart backoff 5 10 session protection (neighbor) (__REGEX__) password encrypted __REGEX__ (neighbor) (__REGEX__) password encrypted __REGEX__ (neighbor) (__REGEX__) password encrypted __REGEX__ igp sync delay 10 label allocate for LLAF ! log neighbor nsr ! interface (__REGEX__) ! interface (__REGEX__) ! ! ======================================================================
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Template-based router configuration audit
by McDarren (Abbot) on Nov 02, 2010 at 14:26 UTC | |
Re: Template-based router configuration audit
by jethro (Monsignor) on Nov 02, 2010 at 14:50 UTC | |
by ccie (Initiate) on Nov 03, 2010 at 10:22 UTC | |
by jethro (Monsignor) on Nov 03, 2010 at 12:15 UTC |
Back to
Seekers of Perl Wisdom