diff options
Diffstat (limited to 'bin/rancid.in')
-rw-r--r-- | bin/rancid.in | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/bin/rancid.in b/bin/rancid.in index a69768e..4b5b12a 100644 --- a/bin/rancid.in +++ b/bin/rancid.in @@ -1,7 +1,8 @@ #! @PERLV_PATH@ ## -## $Id: rancid.in,v 1.209 2006/08/12 02:34:22 heas Exp $ +## $Id: rancid.in,v 1.218 2006/10/05 04:27:43 heas Exp $ ## +## @PACKAGE@ @VERSION@ ## Copyright (C) 1997-2006 by Terrapin Communications, Inc. ## All rights reserved. ## @@ -21,10 +22,14 @@ # # RANCID - Really Awesome New Cisco confIg Differ # -# usage: rancid [-d] [-l] [-f filename | hostname] +# usage: rancid [-dV] [-l] [-f filename | hostname] # use Getopt::Std; -getopts('dfl'); +getopts('dflV'); +if ($opt_V) { + print "@PACKAGE@ @VERSION@\n"; + exit(0); +} $log = $opt_l; $debug = $opt_d; $file = $opt_f; @@ -234,7 +239,7 @@ sub ShowVersion { next; /^System image file is "([^\"]*)"$/ && ProcessHistory("COMMENTS","keysort","F5","!Image: $1\n") && next; - if (/(\S+)\s+(?:\((\S+)\)\s+processor\s+)?\(revision[^)]+\).*with (\S+[kK]) bytes/) { + if (/(\S+)\s+(?:\((\S+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i) { my($proc) = $1; my($cpu) = $2; my($mem) = $3; @@ -267,55 +272,57 @@ sub ShowVersion { s/^/, /; } - if ( $proc eq "CSC") { + if ($proc eq "CSC") { $type = "AGS"; - } elsif ( $proc eq "CSC4") { + } elsif ($proc eq "CSC4") { $type = "AGS+"; - } elsif ( $proc =~ /^(AS)?25[12][12]/) { + } elsif ($proc =~ /^(AS)?25[12][12]/) { $type = "2500"; - } elsif ( $proc =~ /261[01]/ || $proc =~ /262[01]/ ) { + } elsif ($proc =~ /261[01]/ || $proc =~ /262[01]/ ) { $type = "2600"; - } elsif ( $proc =~ /^36[0246][0-9]/) { + } elsif ($proc =~ /^36[0246][0-9]/) { $type = "3600"; - } elsif ( $proc =~ /^37/) { + } elsif ($proc =~ /^37/) { $type = "3700"; - } elsif ( $proc =~ /^38/) { + } elsif ($proc =~ /^38/) { $type = "3800"; - } elsif ( $proc eq "RSP7000") { + } elsif ($proc eq "RSP7000") { $type = "7500"; - } elsif ( $proc =~ /RSP\d/) { + } elsif ($proc =~ /RSP\d/) { $type = "7500"; - } elsif ( $proc eq "RP1") { + } elsif ($proc eq "RP1") { $type = "7000"; - } elsif ( $proc eq "RP") { + } elsif ($proc eq "RP") { $type = "7000"; - } elsif ( $proc =~ /720[246]/) { + } elsif ($proc =~ /720[246]/) { $type = "7200"; - } elsif ( $proc =~ /1200[48]\/GRP/ || $proc =~ /1201[26]\/GRP/) { + } elsif ($proc =~ /1200[48]\/GRP/ || $proc =~ /1201[26]\/GRP/) { $type = "12000"; - } elsif ( $proc =~ /1201[26]-8R\/GRP/) { + } elsif ($proc =~ /1201[26]-8R\/GRP/) { $type = "12000"; - } elsif ( $proc =~ /WS-C29/) { + } elsif ($proc =~ /WS-C29/) { $type = "2900XL"; $device = "switch"; - } elsif ( $proc =~ /WS-C355/) { + } elsif ($proc =~ /WS-C355/) { $type = "3550"; $device = "switch"; - } elsif ( $proc =~ /WS-C35/) { + } elsif ($proc =~ /WS-C35/) { $type = "3500XL"; $device = "switch"; - } elsif ( $proc =~ /WS-C45/) { + } elsif ($proc =~ /WS-C45/) { $type = "4500"; $device = "switch"; - } elsif ( $proc =~ /6000/) { + } elsif ($proc =~ /6000/) { $type = "6000"; $device = "switch"; - } elsif ( $proc =~ /CISCO76/) { + } elsif ($proc =~ /CISCO76/) { $type = "7600"; $device = "router"; - } elsif ( $proc =~ /1900/) { + } elsif ($proc =~ /1900/) { $type = "1900"; $device = "switch"; + } elsif ( $proc =~ /^73/) { + $type = "7300"; } else { $type = $proc; } @@ -1196,9 +1203,13 @@ sub ShowInventory { ProcessHistory("INVENTORY","","", sprintf("!%-30s %s\n", $1, $2)); next; } - # split PID/VID line - if (/^(PID: \S*)\s*, (VID: \S*)\s*, (SN: \S*)\s*$/) { - ProcessHistory("INVENTORY","","", "!$1\n!$2\n!$3\n"); + # split PID/VID/SN line + if (/^PID: (\S*)\s*, VID: (\S*)\s*, SN: (\S*)\s*$/) { + my($entries) = ""; + $entries .= "!PID: $1\n" if ($1); + $entries .= "!VID: $2\n" if ($2); + $entries .= "!SN: $3\n" if ($3); + ProcessHistory("INVENTORY","","", "$entries"); next; } ProcessHistory("INVENTORY","","","!$_"); @@ -1369,6 +1380,7 @@ sub ShowVLAN { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); + return(1) if /^\s*\^\s*$/; return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if /Ambiguous command/i; @@ -1648,7 +1660,7 @@ sub WriteTerm { } } # prune tacacs/radius server keys - if (/^((tacacs-server|radius-server)\s(\w*[-\s(\s\S+])*\s?key) \w+/ + if (/^((tacacs-server|radius-server)\s(\w*[-\s(\s\S+])*\s?key) \d \w+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 <removed>$'"); next; } |