[rancid] Re: cisco syslog diff

Smirnoff Alexander asmirnoff at gldn.net
Mon Aug 25 09:30:28 UTC 2008


I do following changes in bin/rancid:

# This routine parses "show flash"
sub ShowFlash {
    # skip if this is 7000, 7200, 7500, or 12000; else we end up with
    # redundant data from dir /all slot0:
    print STDERR "    In ShowFlash: $_" if ($debug);
    
    while (<INPUT>) {
        tr/\015//d;
        last if (/^$prompt/);
        next if (/^(\s*|\s*$cmd\s*)$/);
>>        next if /\s+syslog$/;   # syslog file size keeps changing
>>        next if /bytes total/;  # ...which makes the total usage change
        return(1) if ($type =~ /^(12[40]|7)/);
        return(1) if /^\s*\^\s*$/;
        return(1) if /Line has invalid autocommand /;
        return(1) if /(Invalid input detected|Type help or )/;
        return(-1) if (/command authorization failed/i);
        # the pager can not be disabled per-session on the PIX
        if (/^(<-+ More -+>)/) {
            my($len) = length($1);
            s/^$1\s{$len}//;
        }
        
        /\s+(multiple-fs|nv_hdr|vlan\.dat)$/ && next;
        ProcessHistory("FLASH","","","!Flash: $_");
    }
    ProcessHistory("","","","!\n");
    return;
}

# This routine parses "dir /all ((disk|slot)N|bootflash|nvram):"
sub DirSlotN {
    # Skip if this is not a 3600, 7000, 7200, 7500, or 12000.
    print STDERR "    In DirSlotN: $_" if ($debug);

    my($dev) = (/\s([^\s]+):/);

    while (<INPUT>) {
        tr/\015//d;
        last if (/^$prompt/);
        next if (/^(\s*|\s*$cmd\s*)$/);
>>        next if /\s+syslog$/;   # syslog file size keeps changing
>>        next if /bytes total/;  # ...which makes the total usage change
        # return(1) if ($type !~ /^(12[40]|7|36)/);
        return(1) if /^\s*\^\s*$/;
        return(1) if /Line has invalid autocommand /;
        return(1) if /(Invalid input detected|Type help or )/;
        return(1) if /(No such device|Error Sending Request)/i;
        return(1) if /\%Error: No such file or directory/;
        return(1) if /No space information available/;
        return(-1) if /\%Error calling/;
        return(-1) if /(: device being squeezed|ATA_Status time out)/i; # busy
        return(-1) if (/command authorization failed/i);
        return(1) if /(Open device \S+ failed|Error opening \S+:)/;
        # the pager can not be disabled per-session on the PIX
        if (/^(<-+ More -+>)/) {
            my($len) = length($1);
            s/^$1\s{$len}//;
        }

        ProcessHistory("FLASH","","","!Flash: $dev: $_");
    }
    ProcessHistory("","","","!\n");
    return(0);
}

And after Rancid send me messages like this, after every rancid run:

Index: configs/10.4.1.2
===================================================================
retrieving revision 1.3
diff -U 4 -r1.3 10.4.1.2
@@ -38,14 +38,12 @@
  !Flash: Directory of flash:/
  !Flash:     2  -rwx     2774747   Mar 01 1993 00:09:10  c2950-i6q4l2-mz.121-12c.EA1.bin
  !Flash:     3  -rwx          47   Oct 16 2007 11:26:05  private-сonfig.text
  !Flash:     5  -rwx        5645   Oct 16 2007 11:26:05  config.text
- !Flash: 7741440 bytes total (4957184 bytes free)
  !
  !Flash: nvram: Directory of nvram:/
  !Flash: nvram:     1  -rw-        5645              <no date>  startup-config
  !Flash: nvram:     2  ----          47              <no date>  private-config
- !Flash: nvram: 32768 bytes total (27123 bytes free)
  !
  !VTP: VTP Version                     : 2
  !VTP: Configuration Revision          : 23
  !VTP: Maximum VLANs supported locally : 64

With only "-"  of bytes total in Flash.

-----Original Message-----
From: Daniel Medina [mailto:daniel.medina at gmail.com] 
Sent: Friday, August 22, 2008 12:31 AM
To: Lance Vermilion
Cc: Smirnoff Alexander; rancid-discuss at shrubbery.net
Subject: Re: [rancid] Re: cisco syslog diff

On Thu, Aug 21, 2008 at 11:12:46AM -0700, Lance Vermilion wrote:
> the other option is to write some custom pieces to not include or modify the
> command for dir to exclude things you don't want to include.
> 
> dir | e syslog
> 
> something like that. You may have to escape the |, you will need to mess
> with it a little.

 And you'd have to remember to skip over the "bytes total" / "bytes free" which
will also be changing.

 ShowFlash() and DirSlotN() in rancid might be the right places to do this,
updating the INPUT loop, ex:

    next if /\s+syslog$/;   # syslog file size keeps changing
    next if /bytes total/;  # ...which makes the total usage change

or something smarter, if you want to see that the file is present, but don't
care about the updated filesize and timestamp.

-- 
Dan


More information about the Rancid-discuss mailing list