in reply to Re: Template-based router configuration audit
in thread Template-based router configuration audit
Inventory, such as IPs, neighbors, interfaces, etc., is not known in advance. So the Template module not really useful IMO. I want to collect inventory from device configurations, and later import as csv in excel, where simple sort by desired column could outline anomalies. By scanning device configurations against "templates" I make sure that configuration sections are correct, and at the same time acquire inventory.
I wanted this task to b simple for end user, hence no regex in the "template" (or mask) file.The template example above is transformed in following regex string $mask_tmp:
And then I loop (mask can be found multiple times in the configuration) this mask through device configuration stored in $current_cfg as follows:(mpls ldp) (router-id) ([^\n]+) nsr graceful-restart backoff 5 10 session protection (neighbor) ([^\n]+) password encrypted [^\n]+ (neighbor) ([^\n]+) password encrypted [^\n]+ (neighbor) ([^\n]+) password encrypted [^\n]+ igp sync delay 10 label allocate for LLAF ! log neighbor nsr ! interface ([^\n]+) ! interface ([^\n]+) ! !
Result is the following:while (@MASK_VARIABLES = $current_cfg =~ /$mask_tmp/s) { $MASK_VARIABLES = join(",",@MASK_VARIABLES); $MASK_SEEN{$hostname}{$mask} = "YES"; $MASK_COUNT{$hostname}{$mask}++; # ($MASK_VARIABLES[1] =~ /\w+/) && do { print "$hostname,$MASK_VARIABLES\n"; }; # # remove identified cfg section from router configuration # $current_cfg =~ s/$mask_tmp//s; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Template-based router configuration audit
by jethro (Monsignor) on Nov 03, 2010 at 12:15 UTC |