ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.62k stars 1.31k forks source link

Show command on Netmiko not displaying any output!!! #688

Closed larby22 closed 5 years ago

larby22 commented 6 years ago

I ran the following commands below , please help

user@ubuntu:~$ python Python 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import netmiko from netmiko import ConnectHandler CiscoASR = { ... 'device_type':'cisco_xr', ... 'ip':'192.168.X.X', ... 'username':'verify', ... 'password':'Verify', ... 'port':'22', ... 'verbose': False, ... } net_connect = ConnectHandler(**CiscoASR) output = net_connect.send_command('show version') print output 0/CPU0:MY_ASR9K#show version

Thu Jan 18 18:11:00.878 WAT

output = net_connect.send_command('show ip int brief') print output 0:IKY_PE_ASR9K_01#show ip RP/0/RSP0/CPU0:MY_ASR9K#show ip int RP/0/RSP0/CPU0:MY_ASR9K#show ip int brief

larby22 commented 6 years ago

@ktbyers kindly help

ktbyers commented 6 years ago

@larby22 Try this:

# code above here is the same...
net_connect = ConnectHandler(**CiscoASR)
net_connect.ansi_escape_codes = True
output = net_connect.send_command('show version')
print output
print '-' * 80
print repr(output)
larby22 commented 6 years ago

@ktbyers thanks for checking see output below. It's still not displaying any output.

from netmiko import ConnectHandler import netmiko CiscoASR = { ... 'device_type': 'cisco_xr', ... 'ip': '192.168.x.x', ... 'username': 'verify', ... 'password': 'verify', ... 'port': 22, ... 'verbose': False, ... } net_connect = ConnectHandler(**CiscoASR) net_connect.ansi_escape_codes = True output = net_connect.send_command('show version') print output 0/CPU0:MY_ASR9K#show version

Tue Jan 23 01:27:02.174 WAT

print '-' * 80

print repr(output) u'0/CPU0:MY_ASR9K_01#show version\n\nTue Jan 23 01:27:02.174 WAT\n'

ktbyers commented 6 years ago

What does the actual show version look like when you do it manually?

Kirk

larby22 commented 6 years ago

@ktbyers see below sample extract.

MY_ASR9K_01#show version Tue Jan 23 01:43:17.548 WAT

Cisco IOS XR Software, Version 5.3.4[Default] Copyright (c) 2017 by Cisco Systems, Inc.

ROM: System Bootstrap, Version 10.50(c) 1994-2014 by Cisco Systems, Inc.

MY_ASR9K_01 uptime is 10 weeks, 6 days, 11 hours, 53 minutes System image file is "disk0:asr9k-os-mbi-5.3.4.sp3-1.0.0/0x100305/mbiasr9k-rsp3.vm"

cisco ASR9K Series (Intel 686 F6M14S4) processor with 33554432K bytes of memory. Intel 686 F6M14S4 processor at 1899MHz, Revision 2.174 ASR 9010 8 Line Card Slot Chassis with V2 DC PEM

4 Management Ethernet 2 FastEthernet 2 MgmtMultilink 2 SONET/SDH 52 Serial network interface(s) 1 Multilink network interface(s) 40 GigabitEthernet 48 TenGigE 48 DWDM controller(s) 48 WANPHY controller(s) 375k bytes of non-volatile configuration memory. 6271M bytes of hard disk. 25012208k bytes of disk0: (Sector size 512 bytes). 25012208k bytes of disk1: (Sector size 512 bytes).

Configuration register on node 0/RSP0/CPU0 is 0x2102 Boot device on node 0/RSP0/CPU0 is disk0: Package active on node 0/RSP0/CPU0: iosxr-infra-5.3.4.sp3, V 1.0.0[SMU], Cisco Systems, at disk0:iosxr-infra-5.3.4.sp3-1.0.0 Built on Wed Jun 14 19:02:45 WAT 2017 By iox-lnx-007 in /san1/EFR/sp_r53x_5_3_4/workspace for pie

asr9k-base-5.3.4.sp3, V 1.0.0[SMU], Cisco Systems, at disk0:asr9k-base-5.3.4.sp3-1.0.0 Built on Wed Jun 14 19:02:45 WAT 2017 By iox-lnx-007 in /san1/EFR/sp_r53x_5_3_4/workspace for pie

iosxr-mgbl-5.3.4.sp3, V 1.0.0[SMU], Cisco Systems, at disk0:iosxr-mgbl-5.3.4.sp3-1.0.0 Built on Wed Jun 14 19:02:45 WAT 2017 By iox-lnx-007 in /san1/EFR/sp_r53x_5_3_4/workspace for pie

iosxr-ce-5.3.4.sp3, V 1.0.0[SMU], Cisco Systems, at disk0:iosxr-ce-5.3.4.sp3-1.0.0 Built on Wed Jun 14 19:02:45 WAT 2017 By iox-lnx-007 in /san1/EFR/sp_r53x_5_3_4/workspace for pie

asr9k-fwding-5.3.4.sp3, V 1.0.0[SMU], Cisco Systems, at disk0:asr9k-fwding-5.3.4.sp3-1.0.0 Built on Wed Jun 14 19:02:45 WAT 2017 By iox-lnx-007 in /san1/EFR/sp_r53x_5_3_4/workspace for pie

ktbyers commented 6 years ago

@larby22 Can you turn on logging and find what you see.

I suspect the prompt is getting messed up because of ANSI escape codes which is causing Netmiko to not properly find the command output.

larby22 commented 6 years ago

Thanks @ktbyers I am quit new to netmiko . Kindly help point me to how i can enable logging. Thanks in advance

ktbyers commented 6 years ago

@larby22 My bad...I forgot to include the link of how to enable logging earlier...

https://github.com/ktbyers/netmiko/blob/develop/COMMON_ISSUES.md#enable-netmiko-logging-of-all-reads-and-writes-of-the-communications-channel

larby22 commented 6 years ago

Hello @ktbyers , Kindly find attached debug output. The debug output displays the expected output in the log but not on the terminal. Debug_log_netmiko.txt

larby@ubuntu:~$ sudo python pecheck3.py

SHOW LOG OF LAST 100_10.10.20.17 <<<<<<<<<<< Y_ASR9K#show logging RP/0/RSP0/CPU0:MY_ASR9K #show logging last RP/0/RSP0/CPU0:MY_ASR9K #show logging last 100

END OF LAST 100 LOGS_10.10.20.17 <<<<<<<<<<

ktbyers commented 6 years ago

I am going to delete all of the PanOS comments from this issue (as two separate possible issues are getting conflated together and it is confusing).

ktbyers commented 6 years ago

@larby22 The commands there weren't show version? I thought you weere executing show version.

Kirk

larby22 commented 6 years ago

Hi @ktbyers sorry for the mix up. I have attached the log output for "show version" .

Also kindly find below output on the terminal

from netmiko import ConnectHandler import netmiko import logging

logging.basicConfig(filename='test.log',level=logging.DEBUG) logger = logging.getLogger("netmiko")

CiscoASR = { ... 'device_type': 'cisco_xr', ... 'ip': '192.168.2.1', ... 'username': 'verify', ... 'password': 'verify', ... 'port': 22, ... 'verbose': False, ... } net_connect = ConnectHandler(**CiscoASR) net_connect.ansi_escape_codes = True output = net_connect.send_command('show version') print output 0/CPU0:MY_PE_ASR9K_01#show version

Sun Feb 18 10:39:05.001 WAT

Debug_log_netmiko(show version).txt

ktbyers commented 6 years ago

Do you have timestamps turned on (for this device)? If so I would probably turn those off.

@larby22

artyomovs commented 4 years ago

Hi guys. @larby22 @ktbyers

Did you figure this out? I've got the same issue. No output in netmiko send_command.

Here is my script:

from netmiko import ConnectHandler
cli = ConnectHandler(   device_type='cisco_ios_telnet',
                        ip='10.0.20.1',
                        username ='cisco',
                        password= 'cisco',
                        secret= 'cisco')

cli.enable()
cli.ansi_escape_codes = True
result = cli.send_command('show ip int br')
print(result)

output is empty.

ktbyers commented 4 years ago

@artyomovs Are you using Netmiko 3.0.0? It just recently came out. If not, can you re-test with Netmiko 3.0.0.

Thanks, Kirk