Discussion:
[rancid] Adding IOS Commands to Rancid 3.1
Chip Pleasants
2015-04-08 20:18:27 UTC
Permalink
I couldn't find anything that discussed this in detail, so I'm hoping
someone could give me a little direction. I'm trying to add a new command
in rancid 3.1 for IOS devices and its not issuing the command i'm trying to
add when running rancid. it doesn't seem its looking at the
rancid.types.conf file when running. I've modified the
/etc/rancid/rancid.types.conf and the /usr/share/perl5/vendor_perl/rancid/
ios.pm. I've added my additions right about the "chow version" statement in
both files. Below are my the additions to each file and some debug out when
I run rancid. Thanks in advance for taking the time to assist and let me
know if I can provide any more information.


-Chip



[***@server02 ~]$ cat /etc/rancid/rancid.types.conf | grep
ShowArchiveConfigDiff
cisco;command;ios::ShowArchiveConfigDiff;show archive config diff


[***@server02 ~]$ sudo nano /usr/share/perl5/vendor_perl/rancid/ios.pm
# This routine parses "ShowArchiveConfigDiff"
sub ShowArchiveConfigDiff {
my($INPUT, $OUTPUT, $cmd) = @_;
print STDERR " In ShowArchiveConfigDiff: $_" if ($debug);

while (<$INPUT>) {
tr/\015//d;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
next if (/^\s+\^$/);
return(1) if (/Line has invalid autocommand /);
return(1) if (/(invalid (input|command) detected|type help or )/i);

if (/current template is/) {
ProcessHistory("COMMENTS","keysort","IO","!Diff: $_");
}
}
ProcessHistory("COMMENTS","keysort","IO","!\n");
return(0);
}
[***@server02 ~]$ /usr/libexec/rancid/rancid -t cisco -d router.inc.net
loadtype: device type cisco
loadtype: found device type cisco in /etc/rancid/rancid.types.base
executing clogin -t 90 -c"show version;show redundancy secondary;show
idprom backplane;show install active;show env all;show rsp
chassis-info;show gsr chassis;show diag chassis-info;show boot;show
bootvar;show variables boot;show flash;dir /all nvram:;dir /all
bootflash:;dir /all slot0:;dir /all disk0:;dir /all slot1:;dir /all
disk1:;dir /all slot2:;dir /all disk2:;dir /all harddisk:;dir /all
harddiska:;dir /all harddiskb:;dir /all sup-bootdisk:;dir /all
sup-bootflash:;dir /all sup-microcode:;dir /all slavenvram:;dir /all
slavebootflash:;dir /all slaveslot0:;dir /all slavedisk0:;dir /all
slaveslot1:;dir /all slavedisk1:;dir /all slaveslot2:;dir /all
slavedisk2:;dir /all slavesup-bootflash:;dir /all sec-nvram:;dir /all
sec-bootflash:;dir /all sec-slot0:;dir /all sec-disk0:;dir /all
sec-slot1:;dir /all sec-disk1:;dir /all sec-slot2:;dir /all sec-disk2:;show
controllers;show controllers cbus;show diagbus;show diag;show capture;show
module;show spe version;show c7200;show inventory raw;show vtp status;show
vlan;show vlan-switch;show switch detail;show sdm prefer;show system
mtu;show debug;show shun;more system:running-config;show running-config
view full;show running-config;write term" router.inc.net
PROMPT MATCH: router#
HIT COMMAND:router#show version
In ShowVersion: router#show version
TYPE = ASR1001
HIT COMMAND:router#show redundancy secondary
In ShowRedundancy: router#show redundancy secondary
HIT COMMAND:router#show idprom backplane
In ShowIDprom: router#show idprom backplane
HIT COMMAND:router#show install active
In ShowInstallActive: router#show install active
HIT COMMAND:router#show env all
In ShowEnv: router#show env all
HIT COMMAND:router#show rsp chassis-info
In ShowRSP: router#show rsp chassis-info
HIT COMMAND:router#show gsr chassis
In ShowGSR: router#show gsr chassis
HIT COMMAND:router#show diag chassis-info
In ShowGSR: router#show diag chassis-info
HIT COMMAND:router#show boot
In ShowBoot: router#show boot
HIT COMMAND:router#show bootvar
In ShowBoot: router#show bootvar
HIT COMMAND:router#show variables boot
In ShowBoot: router#show variables boot
HIT COMMAND:router#show flash
In ShowFlash: router#show flash
HIT COMMAND:router#dir /all nvram:
In DirSlotN: router#dir /all nvram:
HIT COMMAND:router#dir /all bootflash:
In DirSlotN: router#dir /all bootflash:
HIT COMMAND:router#dir /all slot0:
In DirSlotN: router#dir /all slot0:
HIT COMMAND:router#dir /all disk0:
In DirSlotN: router#dir /all disk0:
HIT COMMAND:router#dir /all slot1:
In DirSlotN: router#dir /all slot1:
HIT COMMAND:router#dir /all disk1:
In DirSlotN: router#dir /all disk1:
HIT COMMAND:router#dir /all slot2:
In DirSlotN: router#dir /all slot2:
HIT COMMAND:router#dir /all disk2:
In DirSlotN: router#dir /all disk2:
HIT COMMAND:router#dir /all harddisk:
In DirSlotN: router#dir /all harddisk:
HIT COMMAND:router#dir /all harddiska:
In DirSlotN: router#dir /all harddiska:
HIT COMMAND:router#dir /all harddiskb:
In DirSlotN: router#dir /all harddiskb:
HIT COMMAND:router#dir /all sup-bootdisk:
In DirSlotN: router#dir /all sup-bootdisk:
HIT COMMAND:router#dir /all sup-bootflash:
In DirSlotN: router#dir /all sup-bootflash:
HIT COMMAND:router#dir /all sup-microcode:
In DirSlotN: router#dir /all sup-microcode:
HIT COMMAND:router#dir /all slavenvram:
In DirSlotN: router#dir /all slavenvram:
HIT COMMAND:router#dir /all slavebootflash:
In DirSlotN: router#dir /all slavebootflash:
HIT COMMAND:router#dir /all slaveslot0:
In DirSlotN: router#dir /all slaveslot0:
HIT COMMAND:router#dir /all slavedisk0:
In DirSlotN: router#dir /all slavedisk0:
HIT COMMAND:router#dir /all slaveslot1:
In DirSlotN: router#dir /all slaveslot1:
HIT COMMAND:router#dir /all slavedisk1:
In DirSlotN: router#dir /all slavedisk1:
HIT COMMAND:router#dir /all slaveslot2:
In DirSlotN: router#dir /all slaveslot2:
HIT COMMAND:router#dir /all slavedisk2:
In DirSlotN: router#dir /all slavedisk2:
HIT COMMAND:router#dir /all slavesup-bootflash:
In DirSlotN: router#dir /all slavesup-bootflash:
HIT COMMAND:router#dir /all sec-nvram:
In DirSlotN: router#dir /all sec-nvram:
HIT COMMAND:router#dir /all sec-bootflash:
In DirSlotN: router#dir /all sec-bootflash:
HIT COMMAND:router#dir /all sec-slot0:
In DirSlotN: router#dir /all sec-slot0:
HIT COMMAND:router#dir /all sec-disk0:
In DirSlotN: router#dir /all sec-disk0:
HIT COMMAND:router#dir /all sec-slot1:
In DirSlotN: router#dir /all sec-slot1:
HIT COMMAND:router#dir /all sec-disk1:
In DirSlotN: router#dir /all sec-disk1:
HIT COMMAND:router#dir /all sec-slot2:
In DirSlotN: router#dir /all sec-slot2:
HIT COMMAND:router#dir /all sec-disk2:
In DirSlotN: router#dir /all sec-disk2:
HIT COMMAND:router#show controllers
In ShowContAll: router#show controllers
HIT COMMAND:router#show controllers cbus
In ShowContCbus: router#show controllers cbus
HIT COMMAND:router#show diagbus
In ShowDiagbus: router#show diagbus
HIT COMMAND:router#show diag
In ShowDiag: router#show diag
HIT COMMAND:router#show capture
In ShowCapture: router#show capture
HIT COMMAND:router#show module
In ShowModule: router#show module
HIT COMMAND:router#show spe version
In ShowSpeVersion: router#show spe version
HIT COMMAND:router#show c7200
In ShowC7200: router#show c7200
HIT COMMAND:router#show inventory raw
In ShowInventory: router#show inventory raw
HIT COMMAND:router#show vtp status
In ShowVTP: router#show vtp status
HIT COMMAND:router#show vlan
In ShowVLAN: router#show vlan
HIT COMMAND:router#show vlan-switch
In ShowVLAN: router#show vlan-switch
HIT COMMAND:router#show switch detail
In ShowDetail: router#show switch detail
HIT COMMAND:router#show sdm prefer
In ShowSDM: router#show sdm prefer
HIT COMMAND:router#show system mtu
In ShowMTU: router#show system mtu
HIT COMMAND:router#show debug
In ShowDebug: router#show debug
HIT COMMAND:router#show shun
In ShowShun: router#show shun
HIT COMMAND:router#more system:running-config
In WriteTerm: router#more system:running-config
HIT COMMAND:router#show running-config view full
In WriteTerm: router#show running-config view full
HIT COMMAND:router#show running-config
In WriteTerm: router#show running-config
HIT COMMAND:router#write term
In WriteTerm: router#write term
[***@server02 ~]$
heasley
2015-04-08 22:36:08 UTC
Permalink
Post by Chip Pleasants
I couldn't find anything that discussed this in detail, so I'm hoping
someone could give me a little direction. I'm trying to add a new command
in rancid 3.1 for IOS devices and its not issuing the command i'm trying to
add when running rancid. it doesn't seem its looking at the
rancid.types.conf file when running. I've modified the
/etc/rancid/rancid.types.conf and the /usr/share/perl5/vendor_perl/rancid/
ios.pm. I've added my additions right about the "chow version" statement in
both files. Below are my the additions to each file and some debug out when
I run rancid. Thanks in advance for taking the time to assist and let me
know if I can provide any more information.
You should copy the cisco definition from rancid.types.base to
rancid.types.conf and give it a new name.

rancid looks in the base file first, and new installations will overwrite
that file.
Chip Pleasants
2015-04-08 23:58:03 UTC
Permalink
Thank you very much for assisting. Was I right in modifying the ios.pm? By
definition do you mean something like below? I'm assuming if I wanted to
use this definition I'd have to change devices in router.db that I wanted
to run this command on? If it does work this way I suppose I'll want to
add all the other commands normally baked in the cisco definition?


# Custom Commands for Cisco IOS devices
cisco-custom;script;rancid -t cisco
cisco-custom;login;clogin
cisco-custom;module;ios
cisco-custom;inloop;ios::inloop
cisco-custom;command;ios::ShowArchiveConfigDiff;show archive config diff


-Chip
Post by Chip Pleasants
Post by Chip Pleasants
I couldn't find anything that discussed this in detail, so I'm hoping
someone could give me a little direction. I'm trying to add a new command
in rancid 3.1 for IOS devices and its not issuing the command i'm trying
to
Post by Chip Pleasants
add when running rancid. it doesn't seem its looking at the
rancid.types.conf file when running. I've modified the
/etc/rancid/rancid.types.conf and the
/usr/share/perl5/vendor_perl/rancid/
Post by Chip Pleasants
ios.pm. I've added my additions right about the "chow version"
statement in
Post by Chip Pleasants
both files. Below are my the additions to each file and some debug out
when
Post by Chip Pleasants
I run rancid. Thanks in advance for taking the time to assist and let me
know if I can provide any more information.
You should copy the cisco definition from rancid.types.base to
rancid.types.conf and give it a new name.
rancid looks in the base file first, and new installations will overwrite
that file.
heasley
2015-04-09 15:13:50 UTC
Permalink
Post by Chip Pleasants
Thank you very much for assisting. Was I right in modifying the ios.pm? By
you can do that; again it will be overwritten by the next installation.
you can create a separate pm for this command and include it with another
module line - i cant recall if i added that in 3.1 or 3.2.
Post by Chip Pleasants
definition do you mean something like below? I'm assuming if I wanted to
use this definition I'd have to change devices in router.db that I wanted
to run this command on? If it does work this way I suppose I'll want to
add all the other commands normally baked in the cisco definition?
yes, yes, yes.
Post by Chip Pleasants
# Custom Commands for Cisco IOS devices
cisco-custom;script;rancid -t cisco
cisco-custom;login;clogin
cisco-custom;module;ios
cisco-custom;inloop;ios::inloop
cisco-custom;command;ios::ShowArchiveConfigDiff;show archive config diff
cisco-custom;module;ios
cisco-custom;module;myios
cisco-custom;command;ios::ShowVersion;show version
cisco-custom;command;ios::etc etc
cisco-custom;command;myios::ShowArchiveConfigDiff;show archive config diff

or if you wanted ShowVersion to do something different; you could create
your own:
cisco-custom;module;myios
cisco-custom;command;myios::ShowVersion;show version
cisco-custom;command;ios::etc etc
Chip Pleasants
2015-04-10 13:39:50 UTC
Permalink
I'm making some strides, but still not getting it to work. I made the
changes discussed in the previous message except creating a new perl
module. It looks like it issues the command from the output below, but
nothing shows up in the file. I'm expecting things starting with !Difff.
Does there need to be more logic for the output?



[***@server02 ~]$ cat /etc/rancid/rancid.types.conf
# Custom Commands for Cisco IOS devices
cisco-ios;script;rancid -t cisco-ios
cisco-ios;login;clogin
cisco-ios;module;ios
cisco-ios;inloop;ios::inloop
cisco-ios;command;ios::ShowArchiveConfigDiff;show archive config diff




[***@server02 ~]$ cat /usr/share/perl5/vendor_perl/rancid/ios.pm
# This routine parses "ShowArchiveConfigDiff"
sub ShowArchiveConfigDiff {
my($INPUT, $OUTPUT, $cmd) = @_;
print STDERR " In ShowArchiveConfigDiff: $_" if ($debug);

while (<$INPUT>) {
tr/\015//d;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
next if (/^\s+\^$/);
return(1) if (/Line has invalid autocommand /);
return(1) if (/(invalid (input|command) detected|type help or )/i);

if (/current template is/) {
ProcessHistory("COMMENTS","keysort","IO","!Diff: $_");
}
}
ProcessHistory("COMMENTS","keysort","IO","!\n");
return(0);
}



[***@server02 ~]$ /usr/libexec/rancid/rancid -t cisco-ios -d
router.inc.net
loadtype: device type cisco-ios
loadtype: found device type cisco-ios in /etc/rancid/rancid.types.conf
executing clogin -t 90 -c"show archive config diff;show version;show
redundancy secondary;show idprom backplane;show install active;show env
all;show rsp chassis-info;show gsr chassis;show diag chassis-info;show
boot;show bootvar;show variables boot;show flash;dir /all nvram:;dir /all
bootflash:;dir /all slot0:;dir /all disk0:;dir /all slot1:;dir /all
disk1:;dir /all slot2:;dir /all disk2:;dir /all harddisk:;dir /all
harddiska:;dir /all harddiskb:;dir /all sup-bootdisk:;dir /all
sup-bootflash:;dir /all sup-microcode:;dir /all slavenvram:;dir /all
slavebootflash:;dir /all slaveslot0:;dir /all slavedisk0:;dir /all
slaveslot1:;dir /all slavedisk1:;dir /all slaveslot2:;dir /all
slavedisk2:;dir /all slavesup-bootflash:;dir /all sec-nvram:;dir /all
sec-bootflash:;dir /all sec-slot0:;dir /all sec-disk0:;dir /all
sec-slot1:;dir /all sec-disk1:;dir /all sec-slot2:;dir /all sec-disk2:;show
controllers;show controllers cbus;show diagbus;show diag;show capture;show
module;show spe version;show c7200;show inventory raw;show vtp status;show
vlan;show vlan-switch;show switch detail;show sdm prefer;show system
mtu;show debug;show shun;more system:running-config;show running-config
view full;show running-config;write term" router.inc.net
PROMPT MATCH: router#
HIT COMMAND:router#show archive config diff
In ShowArchiveConfigDiff: router#show archive config diff



router#sh archive config differences
!
!Contextual Config Diffs:
crypto pki certificate chain TP-self-signed-1439941376
+certificate self-signed 01 nvram:router#7474.cer
+ntp clock-period 36029336
crypto pki certificate chain TP-self-signed-1439941376
-certificate self-signed 01
-308202BE 30820227 A0030201 02020101 300D0609 2A864886 F70D0101 04050030
-63312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274
-69666963 6174652D 31343339 39343133 37363130 302E0609 2A864886 F70D0109
-02162143 4D48312D 49444631 302D4130 312E646F 6D61696E 30312E76 63647369
-2E6E6574 301E170D 39333033 30313030 30323439 5A170D32 30303130 31303030
-3030305A 3063312F 302D0603 55040313 26494F53 2D53656C 662D5369 676E6564
-2D436572 74696669 63617465 2D313433 39393431 33373631 30302E06 092A8648
-86F70D01 09021621 434D4831 2D494446 31302D41 30312E64 6F6D6169 6E30312E
-76636473 692E6E65 7430819F 300D0609 2A864886 F70D0101 01050003 818D0030
-81890281 8100A2CC 9B49301D 797D5BC5 97A5358C B59D932E 1435D3C3 C03B3E7B
-BA351D78 1F3705DA D3C91C08 C47BD867 3047AB49 A31E5EC8 5B449984 8D78A2C0
-E7BBC91E B286EBAB C2E105DB 1E1CF2AE BEC48BD6 4B1A247F DB6A1CD8 DEBE1505
-0F5DE00D C28D5A49 D6F9D076 120E14EC FDDEF22A 3173AF94 BC3CE14D 9B1160EF
-9098D071 CFE50203 010001A3 8181307F 300F0603 551D1301 01FF0405 30030101
-FF302C06 03551D11 04253023 8221434D 48312D49 44463130 2D413031 2E646F6D
-61696E30 312E7663 6473692E 6E657430 1F060355 1D230418 30168014 9B3F993D
-E8086DD2 CC598472 04B43B3A D2309645 301D0603 551D0E04 1604149B 3F993DE8
-086DD2CC 59847204 B43B3AD2 30964530 0D06092A 864886F7 0D010104 05000381
-81004365 4AC25D08 C9AD3506 F146FBFA B51487AE EB8BBDD6 C5E18571 1320D367
-FE26C7C5 402535FD 80A267E6 1AAF099A D034CED7 5EDA462C FC465FB3 CD02B792
-72455D7D A1440B68 54AE7AB9 F5E5B42F 339D793B B315645C C29FE3A7 EA5EB2D9
-76DD8DF5 C0A0F984 864451CB 867F2869 73493329 1CACE7B4 6313183C CB38B6DC
FC02
-quit
-ntp clock-period 36029341

router#

-Chip
Post by heasley
Post by Chip Pleasants
Thank you very much for assisting. Was I right in modifying the ios.pm?
By
you can do that; again it will be overwritten by the next installation.
you can create a separate pm for this command and include it with another
module line - i cant recall if i added that in 3.1 or 3.2.
Post by Chip Pleasants
definition do you mean something like below? I'm assuming if I wanted to
use this definition I'd have to change devices in router.db that I wanted
to run this command on? If it does work this way I suppose I'll want to
add all the other commands normally baked in the cisco definition?
yes, yes, yes.
Post by Chip Pleasants
# Custom Commands for Cisco IOS devices
cisco-custom;script;rancid -t cisco
cisco-custom;login;clogin
cisco-custom;module;ios
cisco-custom;inloop;ios::inloop
cisco-custom;command;ios::ShowArchiveConfigDiff;show archive config diff
cisco-custom;module;ios
cisco-custom;module;myios
cisco-custom;command;ios::ShowVersion;show version
cisco-custom;command;ios::etc etc
cisco-custom;command;myios::ShowArchiveConfigDiff;show archive config diff
or if you wanted ShowVersion to do something different; you could create
cisco-custom;module;myios
cisco-custom;command;myios::ShowVersion;show version
cisco-custom;command;ios::etc etc
Loading...