OpenNetAdmin

Search:   

cisco_cfg

cisco_cfg is actually a few tools in one. Their job is to perform two distinct tasks for you.

  1. Provide a standardized way to push configuration data to Cisco devices and store the updates in NVRAM (write mem)
  2. Provide a standardized way to execute most IOS commands and return their result back to stdout. This is similar to what many refer to as “looking glass”

Requirements

  • Optional: TCL/expect – if you use the cisco_cfg_expect method
  • Optional: snmputils (snmpset,snmpget,snmpwalk) – if you use the cisco_cfg_snmp methods

Install

  • Download – FIXME, not released yet, its in pre-release stages.
  • tar -zxvf cisco_cfg.tar.gz
  • cd cisco_cfg
  • make

Usage

cisco_cfg

This is a wrapper script around cisco_cfg_expect and cisco_cfg_snmp. It will use the two methods of communications to try its best to ensure that your configuration file was pushed to the device. It allows you to specify the order in which to try to communicate to the remote device. Depending on your environment, you may prefer one method over the other. (I like snmp!). It is intended that you would use the cisco_cfg script as the standard method of pushing configuration as opposed to one of the other two commands directly. In the event that another method is developed, your scripts and processes wont need to be adjusted.

cisco_cfg_expect

Copies the specified file name contents to the remote device using the expect scripting language. If desired, it will also save the configuration using a “write mem” command. This method requires a user with “enable” level privileges as it will enter the “config t” mode of the device and push the contents of the file line by line. Depending on the commands you are sending, this could terminate your connection, so be careful or use the snmp method.

cisco_cfg_snmp

Copies the specified file name contents to the remote device using a series of SNMP set commands to instruct the remote device to tftp copy the file to the remote devices running configuration. This copy is additive and does not replace the existing configuration the same way a copy to startup would. This requires a tftp server to be on the same box as the file that you specify. It also requires an snmp community string with write (or set) privileges on the remote device.

If desired, it will also save the configuration using a “write mem” command. This is an SNMP set command instruction to copy running to startup.

Once the remote device is configured to copy the file from a tftp server, this script will continue to communicate to the remote device to check the status of the copy operation. If it reaches 8 times with a wait time of 2 seconds between each check (thats 16 seconds folks!) then it will fail.

cisco_cmd

Cisco_cmd allows you to execute a single IOS command on a remote device and the output of that command will be returned to stdout. Lets assume that you would like to get the output of a “show user” command from your router. You could issue the following command:

$ cisco_cmd -h router.example.com -u user -p pass -c "sh user"
    Line       User       Host(s)              Idle       Location
 323 vty 1     user2     idle                 00:00:13 10.7.2.5
*324 vty 2     user      idle                 00:00:00 10.1.1.23

  Interface    User               Mode         Idle     Peer Address

router#

Now you can easily pipe this output to other commands such as grep, sort , sed , awk, ip2name etc.

NOTE: cisco_cmd is actually a sub component of cisco_cfg_expect. This is why it is merely a symlink to cisco_cfg_expect. As its name implies, it uses the expect language to log into the device and execute commands.

 
utils/cisco_cfg.txt · Last modified: 2009/02/22 16:54 (external edit)