Discussion:
[rancid] Re: Rancid Last Configured Info
Mike Ashcraft
2007-05-01 23:53:00 UTC
Permalink
Patrick,

I am adding the rancid-discuss list as others may be interested in this
hack as well. My initial post to this subject identified the first
section of code that blocks this output. However, there are two
additional sections of code which also block this, one explicitly
designed to make sure the last configured info is not output, the second
to minimize any comment blocks to only the first line.

Nick and I exchanged a few more e-mails which I have included below
which identify two different hacks I tested. This should give you what
you need. Either will work, don't use both at the same time. I
apologize that these are not in diff format and will take a little
effort to apply. Nick may also be able to provide you with a working
script.

If there is a enough interest, I'll find some time to put together a
patch that is done right and submit it.

Mike

-----Original Message-----
From: Patrick Prue [mailto:***@gmail.com]
Sent: Tuesday, May 01, 2007 4:26 PM
To: Mike Ashcraft
Subject: Rancid Last Configured Info


Does your rancid script functionally give you the last configured
information.?


If so can you please attach it .


Thanks
--
Patrick Prue-GCIH,GCIA
President - Prue Consulting Inc.
(905) 329-9317

-----Original Message-----
From: Mike Ashcraft
Sent: Thursday, March 22, 2007 12:57 PM
To: 'Nick Duda'
Subject: RE: [rancid] Re: Rancid and Last Config changes in Cisco gear
Nick,

I pasted the code segment in as follows and it works for me on a Cisco
6500. (I added an 'i' to make it case insensitive in case this is your
problem. It works with or without for me.)

Mike

# skip the crap
if (/^(##+$|(Building|Current) configuration)/i) {
while (<INPUT>) {
next if (/^Current configuration\s*:/i);
next if (/^:/);
# I want to see the last configuration comments
if (/^! (Last configuration|NVRAM config last)/i) {
ProcessHistory("","","",$_);
next;
}
next if (/^([%!].*|\s*)$/);
next if (/^ip add.*ipv4:/); # band-aid for 3620
12.0S
last;
}
if (defined($config_register)) {
ProcessHistory("","","","!\nconfig-register
$config_register\n");
}
tr/\015//d;


I tweaked it a little more and found that the following works slightly
better (cleaner output), but has more complex edits:

# skip the crap
if (/^(##+$|(Building|Current) configuration)/i) {
while (<INPUT>) {
next if (/^Current configuration\s*:/i);
next if (/^:/);
# next if (/^([%!].*|\s*)$/);
next if (/^ip add.*ipv4:/); # band-aid for 3620
12.0S
last;
}
if (defined($config_register)) {
ProcessHistory("","","","!\nconfig-register
$config_register\n");
}
tr/\015//d;
}

# I want to see the last configuration comments
if (/^! (Last configuration|NVRAM config last)/i) {
ProcessHistory("","","",$_);
next;
}
# some versions have other crap mixed in with the bits in the
# block above
# /^! (Last configuration|NVRAM config last)/ && next;




-----Original Message-----
From: Nick Duda [mailto:***@VistaPrint.com]
Sent: Thursday, March 22, 2007 6:34 AM
To: Mike Ashcraft
Subject: RE: [rancid] Re: Rancid and Last Config changes in Cisco gear

I'll try that...I don't understand why they wouldn't want this there. We
use Rancid for one of the sections on the Sarbanes-Oxley matrix. As part
of that, we need to know when a change is made, who made it. Rancid
doesn't support this...silly. Great product, just need that option.

- Nick


-----Original Message-----
From: Mike Ashcraft [mailto:***@omniture.com]
Sent: Wednesday, March 21, 2007 2:43 PM
To: Nick Duda
Subject: RE: [rancid] Re: Rancid and Last Config changes in Cisco gear

Nick,

It is obvious the developers did not want this feature you are asking
for. A few lines further down in the code there is another catch to
explicitly prevent these two lines from being included:

# some versions have other crap mixed in with the bits in the
# block above
/^! (Last configuration|NVRAM config last)/ && next;

Just commenting this out as well will not work as there is another
section farther down that ensures that only the first line of any block
of comments is output. You need modify the code to output these instead
of skipping them with something like this:

# I want to see the last configuration comments
if (/^! (Last configuration|NVRAM config last)/) {
ProcessHistory("","","",$_);
next;
}

Disclaimer -- I have not tested this, you are on your own. Upgrades to
rancid will remove this change.

Mike




-----Original Message-----
From: Nick Duda [mailto:***@VistaPrint.com]
Sent: Wednesday, March 21, 2007 6:43 AM
To: Nick Duda; Mike Ashcraft; rancid-***@shrubbery.net
Subject: RE: [rancid] Re: Rancid and Last Config changes in Cisco gear

FYI, so this is what my rancid file looks like:


# This routine processes a "write term"
sub WriteTerm {
print STDERR " In WriteTerm: $_" if ($debug);
my($lineauto,$comment,$linecnt) = (0,0,0);

while (<INPUT>) {
tr/\015//d;
last if(/^$prompt/);
return(-1) if (/command authorization failed/i);
return(1) if /(Invalid input detected|Type help or )/;
# the pager can not be disabled per-session on the PIX
s/^<-+ More -+>\s*//;
/Non-Volatile memory is in use/ && return(-1); # NvRAM is
locked
return(0) if ($found_end); # Only do this routine
once
$linecnt++;
$lineauto = 0 if (/^[^ ]/);
# skip the crap
if (/^(##+$|(Building|Current) configuration)/i) {
while (<INPUT>) {
next if (/^Current configuration\s*:/i);
next if (/^:/);
# next if (/^([%!].*|\s*)$/);
next if (/^ip add.*ipv4:/); # band-aid for 3620
12.0S
last;
}

-----Original Message-----
From: rancid-discuss-***@shrubbery.net
[mailto:rancid-discuss-***@shrubbery.net] On Behalf Of Nick Duda
Sent: Wednesday, March 21, 2007 8:37 AM
To: Mike Ashcraft; rancid-***@shrubbery.net
Subject: [rancid] Re: Rancid and Last Config changes in Cisco gear

I commented out that line and still don't get the last configured by in
the rancid alerts..etc.

- Nick

________________________________

From: Patrick Prue [mailto:***@gmail.com]
Sent: Tuesday, May 01, 2007 4:26 PM
To: Mike Ashcraft
Subject: Rancid Last Configured Info


Does your rancid script functionally give you the last configured
information.?


If so can you please attach it .


Thanks
--
Patrick Prue-GCIH,GCIA
President - Prue Consulting Inc.
(905) 329-9317
Loading...