11-03-2021 06:49 AM
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:
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.
11-03-2021 11:16 AM
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
11-03-2021 11:09 PM
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)
11-04-2021 01:26 AM
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
11-04-2021 03:19 AM
The command is "sh interfaces counters gi2" the loop is for the switch ports.
I tried send_command and nothing changed.
11-04-2021 01:50 AM
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")
11-04-2021 01:54 AM
Hey man, I sent you a few PMs if you don't mind could you check them out? Thank you.
11-04-2021 03:17 AM
Sorry, but I didn't find them.
11-04-2021 03:25 AM
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.
11-04-2021 03:33 AM
I'm testing it right now.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide