DX NetOps

 View Only
Expand all | Collapse all

NCM script for Cisco APIC/ACI

  • 1.  NCM script for Cisco APIC/ACI

    Posted Sep 19, 2018 03:46 AM
      |   view attached

    Hi,

     

    I've got Spectrum 10.2.1 installed at my customer on 4 Windows 2012R2 machines (2 SS, 1 OC, 1 Jasper) and customer is using NCM to fetch configurations from monitored devices. I'm using custom device families to fetch configurations from Cisco ASA firewalls, BlueCoat devices,... So I've created a new device family for Cisco APIC devices, used the script from Cisco ASA device family and it doesn't work. I get SPC-OCC-10746 error. SPC-NCM-20007: Connection error: Use of uninitialized value in concatenation (.) or string at C:\Windows\TEMP\script_23 line 115. Host 10.1.1.1: Login has failed. Output: .

     

    When I login to this device through Spectrum (right click - SSH), I log in successfully. The same is ok when I log in by using Putty for example, from Spectroserver.

     

    When I try to capture configuration from command line with this script, I get the same login error. So there is some problem in the script itself, in the way it tries to log in to the device. How can I determine what's causing this and what should I change to get the script working for Cisco APIC? Just to repeat, this script is working for other custom device families. I'm attaching the script.

     

    I've found some information about arguments which are used under "my $ssh = Net::SSH::Expect->new ( host => $deviceIP," and tried to use these for example:

    ssh_option => '-1 -c 3DES' // tried to change authentication mode

    debug => 1 // tried to turn on debugging

    protocol => '1' // tried to change SSH version

    But none of these worked.

     

    Do you maybe have some advice or hint?

     

    Regards

    Attachment(s)

    zip
    script.pl.zip   1 KB 1 version


  • 2.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 19, 2018 10:39 AM

    Doest the device support SSH v2.x?

    Did you try to copy/paste the whole script in an external file and run it manually with the appropriate arguments? With the Perl debugger? Should help a lot!



  • 3.  Re: NCM script for Cisco APIC/ACI

    Broadcom Employee
    Posted Sep 19, 2018 11:46 AM

    Hi Omar

     

    Maybe you can try running the script via command line with debug flag set and it should output debug to the screen for clues.

     

    Place the script in <SPECROOT>/bin

     

    Usage: <script_filename> <device_ip> < SSH _username> < SSH_password> <device_enable_password> <Login_Timeout> <Cmd_Timeout><Debug_flag>

     

    Regards

    Jay V



  • 4.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 03:56 AM

    Device is using SSHv2.

    I've turned on Perl debugger but I don't know how to interpret its output.

    I've looked into Wireshark and I see that keys are exchanged during establishing SSH session but then communication becomes encrypted and it stops. I don't know why.

    Maybe there is some issue with Net::SSH:Expect module which is used in the script. I really cannot find a difference between other devices where script is successfully used and this one which keeps failing.



  • 5.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 04:39 AM

    What is the output when you run it manually?

     

    Could you please also share the script here or at least a snippet showing the line 115?



  • 6.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 04:57 AM

    Script is attached in my first post.

     

    When I run the script manually, I get this:

    e:\Temp>perl script.pl 10.1.1.1 user pass1 pass2 10 10
    Use of uninitialized value in concatenation (.) or string at script.pl line 115.


    Host 10.1.1.1:
    Login has failed. Output:



  • 7.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 05:03 AM

    Ok, the error states that the variable "$login_ouput” is not initialized, which means the function $ssh->login() failed totally. Are you sure the device is reachable? If your password is using any special characters like ‘$', can you do a test and use a very simple password without special characters just to try that? I'm thinking it could cause an issue in case that uses a character which could be reserved in Perl without it being protected.



  • 8.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 05:09 AM

    If this is the case, how come this script works on all other devices? The same password (it includes some special characters) is used.

    Device is reachable because I can log in through Spectrum, through command line, through Putty.



  • 9.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 05:26 AM

    When I try to use the script with pass which doesn't contain special characters (a fake password obviously), I get this output:

    Host 10.1.1.1:
    Login has failed. Didn't see device prompt as expected.



  • 10.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 05:53 AM

    Which version of Perl are you using to run this? The one provided with Spectrum? That means the establishment SSH connection fails…



  • 11.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 05:54 AM

    For this I was more referring to the fact that running it manually from the command line might generate some issues which are handled in the wrapper when Spectrum runs it. Nothing else.



  • 12.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 06:49 AM

    I'm using Perl provided with Spectrum.



  • 13.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 20, 2018 07:01 AM

    I've tested script behavior by using user/pass which doesn't contain any special characters and it failed again with the same error message. When I try to access this device from Spectrum with the same credentials, it succeeds. So special characters are not the issue here.



  • 14.  Re: NCM script for Cisco APIC/ACI
    Best Answer

    Broadcom Employee
    Posted Sep 20, 2018 09:54 AM

    Hi Omar

     

    We have seen error like this: "Use of uninitialized value in concatenation (.) or string”  - https://comm.support.ca.com/kb/error-spcncm20007-is-received-when-doing-a-device-configuration-capture-in-ncm/kb000004147

     

    Typically it was known_hosts file has an invalid SSH key for the device. Try deleting all known_hosts files on the server (they will be recreated when attempting to reconnect to the device)

     

    You can also try Google Search on ‘Use of uninitialized value in concatenation (.) or string'. There are a ton of forums discussing this, which may provide further troubleshooting options.

     

    Regards,

    Jay V



  • 15.  Re: NCM script for Cisco APIC/ACI

    Posted Sep 25, 2018 01:07 AM

    Deleting known_hosts entry doesn't help. I'm searching for other options.



  • 16.  RE: NCM script for Cisco APIC/ACI

    Posted Jan 17, 2021 11:12 AM
    Hi,

    Did you find the solution ?


    I have the same issue with this error