[rancid] jerancid show version parsing

Mack, David A (Dave) dmack at verizon.com
Fri May 15 14:32:06 UTC 2009


Hello! 
	We are current running rancid version, rancid-2.3.2a7 and have
run into a parsing issue for JunOSE devices (ERX-1440s and E320s). It
appears that certain slots are being excluded from the parsed output of
sh version and we have a need to see those slots. Details are provided
below:

Raw output from show version:

BLTMMD-VFTTP-37#sh ver
Juniper Edge Routing Switch E320
Copyright (c) 1999-2008 Juniper Networks, Inc.  All rights reserved.
System Release: e320_9-0-1p0-7-3.rel
        Version: 9.0.1 patch-0.7.3 [BuildId 10622]   (March 8, 2009
21:10)
System running for: 352 days, 19 hours, 13 minutes, 28 seconds
        (since TUE MAY 27 2008 18:15:28 UTC)

slot  state    type    admin  spare   running release     slot uptime  
---- -------- ------- ------- ----- -------------------- --------------
0    standby  LM-10   enabled spare e320_9-0-1p0-7-3.rel      ---      
1     online  LM-4    enabled  ---  e320_9-0-1p0-7-3.rel 16d08h:14m:38s
2      ---      ---     ---    ---          ---               ---      
3     online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel 16d08h:00m:20s
4      ---      ---     ---    ---          ---               ---      
5     online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel 16d07h:59m:56s
6    standby  SRP-320 enabled  ---  e320_9-0-1p0-7-3.rel      ---      
6     online  SFM-320 enabled  ---          ---          16d08h:31m:30s
7     online  SRP-320 enabled  ---  e320_9-0-1p0-7-3.rel 16d08h:31m:38s
7     online  SFM-320 enabled  ---          ---          16d08h:31m:18s
8     online  SFM-320 enabled  ---          ---          16d08h:31m:24s
9     online  SFM-320 enabled  ---          ---          16d08h:31m:11s
10    online  SFM-320 enabled  ---          ---          16d08h:31m:15s
11    online  LM-10   enabled spare e320_9-0-1p0-7-3.rel 10d04h:36m:12s
12    online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel 16d07h:53m:10s
13    online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel 16d07h:52m:17s
14    online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel 16d08h:08m:49s
15    online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel 16d07h:57m:12s
16   inactive LM-10   enabled  ---  e320_9-0-1p0-7-3.rel      ---      

BLTMMD-VFTTP-37#


Here is the parsed output:

!RANCID-CONTENT-TYPE: Juniper_ERX
!
!Chassis type: E320 - a Juniper Edge Routing Switch E320
!
!System Release: e320_9-0-1p0-7-3.rel
!System Version: 9.0.1 patch-0.7.3 [BuildId 10622]   (March 8, 2009
21:10)
!
! slot  state    type    admin  spare   running release    
! ---- -------- ------- ------- ----- --------------------
! 1     online  LM-4    enabled  ---  e320_9-0-1p0-7-3.rel
! 3     online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel
! 5     online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel
! 6     online  SFM-320 enabled  ---          ---         
! 7     online  SRP-320 enabled  ---  e320_9-0-1p0-7-3.rel
! 7     online  SFM-320 enabled  ---          ---         
! 8     online  SFM-320 enabled  ---          ---         
! 9     online  SFM-320 enabled  ---          ---         
! 10    online  SFM-320 enabled  ---          ---         
! 12    online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel
! 13    online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel
! 14    online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel
! 15    online  LM-10   enabled  ---  e320_9-0-1p0-7-3.rel
!

Here is the section of code that I believe that is responsible for
parsing:

# This routine parses "show version"
sub ShowVersion {
    print STDERR "    In ShowVersion: $_" if ($debug);
    my($slots);

    while (<INPUT>) {
        tr/\015//d;
        last if(/^$prompt/);
        next if(/^(\s*|\s*$cmd\s*)$/);
        next if (/^Please wait/i);
        return(-1) if (/command authorization failed/i);

        /^Juniper Edge .* (\S+)$/ &&
                ProcessHistory("COMMENTS","keysort","A1",
                                "!Chassis type: $1 - a $_") && next;
        /^System Release: / &&
                ProcessHistory("COMMENTS","keysort","B1", "!$_") &&
next;
        /^\s+(Version: .*)$/ &&
                ProcessHistory("COMMENTS","keysort","B1", "!System
$1\n") &&
                next;

        if (/^(slot .*)\s+slot uptime/i) {
            ($slots++);
            ProcessHistory("COMMENTS","keysort","B2", "!\n! $1\n");
            next;
        }
        /^(--.*) --+$/ && $slots &&
                ProcessHistory("COMMENTS","keysort","B2", "! $1\n") &&
next;
        if (/^(\d+ +\S+ +(\S+).*) \S+$/ && $slots) {
            my($line) = $1;
            if ($2 != /--+/) {
                ProcessHistory("COMMENTS","keysort","B3", "! $line\n");
            }
            next;
        }
    }
    ProcessHistory("COMMENTS","keysort","B4","!\n");
    return(0);
}


>From the output above you can see that the parsed output is missing
slots 0, 11 and 16. We need to capture those slots as well. As a side
note, the slot uptime is actually useful to us as well. I am not really
very good with PERL, can someone help with this missing output?

Thanks!
Dave


______________________________________________________________
David A. Mack                               (703) 391-7787 (W)
CCIE #6963 (SP and R&S) JNCIE-M #399 CISSP  (703) 431-7617 (C)
email:  dmack at verizon.com
______________________________________________________________
"We are now the knights who say... Ping!"

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 4266 bytes
Desc: not available
Url : http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20090515/a5234d9a/attachment.bin 


More information about the Rancid-discuss mailing list