[rancid] rancid reporting ports in err-disable state

Jon Peatfield J.S.Peatfield at damtp.cam.ac.uk
Tue Mar 29 12:43:27 UTC 2011


Yesterday while trying to disagnose a problem with a user not being able 
to use one port on a switch I noticed that the port in question had 
managed to get into the err-disabled state.

As I'd rather not have to wait for users to complain I've written a 
trivial patch to get rancid to run (for Cisco only):

   show interfaces status err-disabled

which only generates output if ports are in the err-disabled state, and 
lists the reason for each port.

The lines (if any) are added as comments with the prefix SISED as it made 
sense at the time.

Anyway I thought that this might possibly be of use to others.

This patch probably won't cleanly apply for others since the diff was 
generated after applying a patch to add 'show cdp neighbors detail' to the 
list of commands, so if anyone needs a patch against the clean 2.3.6 let 
me know...

-- 
/--------------------------------------------------------------------\
| "Computers are different from telephones.  Computers do not ring." |
|       -- A. Tanenbaum, "Computer Networks", p. 32                  |
---------------------------------------------------------------------|
| Jon Peatfield, _Computer_ Officer, DAMTP,  University of Cambridge |
| Mail:  jp107 at damtp.cam.ac.uk     Web:  http://www.damtp.cam.ac.uk/ |
\--------------------------------------------------------------------/
-------------- next part --------------
--- rancid-2.3.6/bin/rancid.in.errstate	2011-03-28 18:23:07.000000000 +0100
+++ rancid-2.3.6/bin/rancid.in	2011-03-28 18:33:29.000000000 +0100
@@ -602,6 +602,28 @@
     return(0);
 }
 
+# A test routine for parsing the output of "show interfaces status err-disabled"
+sub ShowStatErrDis {
+    print STDERR "    In ShowStatErrDis: $_" if ($debug);	
+
+    while (<INPUT>) {
+        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 (/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}//;
+        }
+        ProcessHistory("COMMENTS","keysort","IO","!SISED: $_");
+    }
+    ProcessHistory("COMMENTS","keysort","IO","!\n");
+    return(0);
+}
 
 # This routine parses "show rsp chassis-info" for the rsp
 # This will create arrays for hw info.
@@ -1935,6 +1957,7 @@
 	{'show variables boot'		=> 'ShowBoot'},
 	{'show flash'			=> 'ShowFlash'},
 	{'show cdp neighbors detail'	=> 'ShowCDPNeighborsDetail'},
+	{'show interfaces status err-disabled'	=> 'ShowStatErrDis'},
 	{'dir /all nvram:'		=> 'DirSlotN'},
 	{'dir /all bootflash:'		=> 'DirSlotN'},
 	{'dir /all slot0:'		=> 'DirSlotN'},


More information about the Rancid-discuss mailing list