DX NetOps

  • 1.  Capture Config for any Device via SSH

    Posted Jan 18, 2017 07:32 PM

    I'm working through ensuring all our devices in our network are backing up their configs via Spectrum, unfortunately as we are all aware Spectrum doesnt have a model for everything under the sun.

     

    I have been modifying an SSH Script we originally got from Cisco to run with ASAs to backup the saved config on devices.

    Basically all the Script does is Run one command and then capture the output..

     

    My question is whether anyone has seen a more generic SSH Script for getting config? I would prefer to not basterdis my existing script but can't start from scratch because the closest I get to programming is powershell..

     

    If there are any docos around on best practices on how to write these scripts I'd love to know about them, or if anyone has there own SSH Scripts the'd like to share that would be great.

     

    Any advice appreciated,

    Cheers



  • 2.  Re: Capture Config for any Device via SSH

    Broadcom Employee
    Posted Jan 20, 2017 01:58 AM

    There is an example here.

    NCM perl ssh des script for get Cisco ASA configuration 

    I hope this helps.



  • 3.  Re: Capture Config for any Device via SSH

    Posted Jan 20, 2017 02:11 AM

    Not really because as I mentioned, that is the example I'm currently working off of. It's very surprising to me that spectrum doesn't have a native way to do this without relying on device profiles. One other fault with using that script is that it outputs the current date which means every day our Configs have one line changed.. so we now have a whole feature we can't use.

    The date thing may not be related to the script and just a part of the way the module outputs the configuration file which should be changed!



  • 4.  RE: Re: Capture Config for any Device via SSH

    Posted Jan 08, 2020 06:02 PM
    i am glad to see someone is posing example scripts again.  Do you or anyone in the thread have an example on what to do for upload of config?

    I have done the custom startup and running scripts from example but have not found one for the upload.



  • 5.  Re: Capture Config for any Device via SSH
    Best Answer

    Posted Jan 20, 2017 03:29 PM

    I requested that CA add an NCM GUI under this idea Spectrum NCM GUI. This would help reduce coding/scripting required by admins and allow more flexibility.

     

    I created a very generic script, based off the NX-OS script, that will work with any device. The script has many variables such as prompt character, show command, port, term length command, and more. It has worked for ASAs, WLCs, proprietary appliances, proxy servers, Cisco IOS, Cisco NX-OS, H3C devices, and more. Using variables will help you produce a generic script and since you have experience modifying the current script, you should be able to add variables easily.

     

    I am not able to share the script I developed, but it's fairly easy to do. You just need to add more input variables, $ARGV, along with the variable the input stores to. It's important to keep the order the same, otherwise you could be passing incorrect variables. I am not a perl programmer, but through various searches I was able to produce what was needed.



  • 6.  Re: Capture Config for any Device via SSH

    Posted Jan 22, 2017 05:07 PM

    Thanks for the advice, it's just messy for a product that can the potential to be better.



  • 7.  Re: Capture Config for any Device via SSH

    Posted Sep 14, 2018 04:45 AM

    Hello Karl Haworth!

     

    I need to do exactly what you described, add more input variables through the $ARGV array on my current "generic" script ive been working with for some device families. I wonder if you could help me?

     

    Heres the thing, I have this Perl Script running on some policies for Cisco IOS devices and some of these devices have its username and password based on the ID that is part of its hostname. So I wonder if I can pass the devices hostname to the script in order to use it to form the credentials to access these devices (with some regex expression probably). 

     

    Is there a way of doing so? Maybe passing the devices hostname attribute or something to the script?

     

    Thank you for any help you can provide!



  • 8.  Re: Capture Config for any Device via SSH

    Posted Sep 14, 2018 11:02 AM

    Danilo,

     

    I no longer work much on this product much, but the idea was to take the existing provided Nexus script from Spectrum through the config manager and modify it. One of the parameters in the script is the pass and the epass. I also use the Additional Script Parameters to pass additional $ARGV[ ] parameters that I called with ex. $ARGV[9].

     

    As far as using a hostname attribute, I am not sure how you'd pass that through, but I would think it is possible. You'd have to figure out how spectrum is inputting the IP into the script and see if you can add additional attributes. The file you're looking for is capture_running.pl

     

    The alternative would be to use their CLI or API to set the NPM_Password attribute on each device which might be the better route. Run a script once per day before your collection that looks for this attribute where it is not set or what's been added in time since the last script run, whatever one works. Then pull the hostname attribute and set the NPM_Password based on that.