[rancid] Inventory output patch for IOS
David Jones
djones at ena.com
Mon Jan 9 15:47:18 UTC 2017
We upgraded from 3.1 to 3.6.1 recently and noticed that the Inventory output changed significantly breaking some parsing/reporting. This also breaks from the Rancid standard for gathering/displaying the ! information.
Rancid 3.1
=========
!Inventory: NAME: "1", DESCR: "ME-3400G-2CS-A"
!Inventory: PID: ME-3400G-2CS-A , VID: V03 , SN: FOC1523V1AG
Rancid 3.6.1
==========
!NAME: "1", DESCR: "ME-3400G-2CS-A"
!PID: ME-3400G-2CS-A
!VID: V03
!SN: FOC1523V1AG
For output consistency, here is a patch for the ios.pm (also applies same block of code in iosxr.pm):
--- ios.pm.orig.3.6.1 2016-12-17 14:07:34.000000000 -0600
+++ ios.pm 2017-01-09 09:19:40.185453144 -0600
@@ -1735,8 +1764,10 @@
next if (/^Load for /);
next if (/^Time source is /);
+ # remove spaces after quotes
+ s/\"\s+/\"/g;
if (/^(NAME: "[^"]*",) (DESCR: "[^"]+")/) {
- ProcessHistory("INVENTORY","","", sprintf("!%-30s %s\n", $1, $2));
+ ProcessHistory("INVENTORY","","", sprintf("!Inventory: %-30s %s\n", $1, $2));
next;
}
# split PID/VID/SN line
@@ -1745,20 +1776,18 @@
my($entries) = "";
# filter <empty>, "0x" and "N/A" lines
if ($pid !~ /^(|0x|N\/A)$/) {
- $entries .= "!PID: $pid\n";
+ $entries .= "PID: $pid";
}
if ($vid !~ /^(|0x|N\/A)$/) {
- $entries .= "!VID: $vid\n";
+ $entries .= ", VID: $vid";
}
if ($sn !~ /^(|0x|N\/A)$/) {
- $entries .= "!SN: $sn\n";
+ $entries .= ", SN: $sn";
}
- ProcessHistory("INVENTORY","","", "$entries");
- next;
}
- ProcessHistory("INVENTORY","","","!$_");
+ ProcessHistory("INVENTORY","","","!Inventory: $_");
}
- ProcessHistory("INVENTORY","","","!\n");
+ ProcessHistory("INVENTORY","","","\n");
Dave Jones
Lead Systems Engineer
Education Networks of America
www.ena.com
More information about the Rancid-discuss
mailing list