cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1929
Views
0
Helpful
9
Replies

CLI Command Empty Output

zeitzytoun
Level 1
Level 1

Hello,

I'm using show interfaces counters cli command to get traffic on SF300 and SG300 28 port cisco switch interfaces. (using netmiko python library based on SSH connection)

It returns the data for the first few ports and then for the rest ones it returns an empty output knowing that there is actual data for those ports.At this point the connection with the switch is still alive, and after passing multiple ports with no results it breaks the connection.(sometimes the result returned for the missing ports is the command of the first port raising this missing data sequence)

 

Ex:

netmiko error.png

in this example the command returns data for interfaces fa1,fa2 and fa3 then for fa4 it starts returning empty result(shown as empty list) then at interface fa6 the result returned is the command "show interfaces counters fa4"

 

Can anyone helps us to figure whats going on?

 

Thanks in advance.

9 Replies 9

Jon Marshall
Hall of Fame
Hall of Fame

 

What happens if you manually SSH in and run the command, do you get the correct output ? 

 

If yes show us the script to see if there is anything in there that could be causing the issue. 

 

Jon

yes, it shows the correct output.

 

Here is a sample of my code:

 

ter_data = switch_connect.send_command_timing("terminal datadump")
if "SF302-08" in switch_model:
        ports_list_to_be_used = SF300_LIST
    elif "SG300-10" in switch_model:
        ports_list_to_be_used = SG300_10_LIST
    elif "SG300-28" in switch_model:
        ports_list_to_be_used = SG300_28_LIST
    for switch_port_name in ports_list_to_be_used:
        try:
            interfaces_counters = switch_connect.send_command_timing(
                f'show interfaces counters {switch_port_name}')
            print(interfaces_counters)

 

So the command is "sh intefaces counters SF300_LIST" as an example ? 

 

I would use a dictionary rather than the if/elif code but doubt that is causing the issue at the moment. 

 

I have never used the send_command_timing command, what if you just use send_command, does it make any difference ? 

 

Jon

 

The command is "sh interfaces counters gi2" the loop is for the switch ports.

 

I tried send_command and nothing changed.

Hello,

 

I looked around for similar scripts, for the Sx300, you might need to set the 'terminal history' command first (which apparently increases the buffer size).

 

I am not sure if you can just add the line below to the beginning of your script:

 

ter_hist = switch_connect.send_command_timing("terminal history")

Hey man, I sent you a few PMs if you don't mind could you check them out? Thank you.

Sorry, but I didn't find them.

Hello,

 

did you try to add the line I suggested to your script ? Or, to test if this is the issue, enter the command 'terminal history' manually from the CLI, then run the script.

I'm testing it right now.