bogdancordos / netbox_scripts

Collection of Netbox custom scripts
5 stars 0 forks source link

netbox_scripts/run_ssh_command.py #1

Closed romarioZ1000 closed 2 years ago

romarioZ1000 commented 2 years ago

Good afternoon! I really like your scripting work.

But I have a problem with netbox_scripts/run_ssh_command.py

Traceback (most recent call last): File "/home/romario/netmiko/mikrotik_1.py", line 11, in net_connect = Netmiko(*dev) File "/home/romario/netmiko/netmiko/netmiko/ssh_dispatcher.py", line 344, in ConnectHandler return ConnectionClass(args, kwargs) File "/home/romario/netmiko/netmiko/netmiko/mikrotik/mikrotik_ssh.py", line 15, in init return super().init(kwargs) File "/home/romario/netmiko/netmiko/netmiko/base_connection.py", line 434, in init self._open() File "/home/romario/netmiko/netmiko/netmiko/base_connection.py", line 440, in _open self._try_session_preparation() File "/home/romario/netmiko/netmiko/netmiko/base_connection.py", line 879, in _try_session_preparation self.session_preparation() File "/home/romario/netmiko/netmiko/netmiko/mikrotik/mikrotik_ssh.py", line 20, in session_preparation self._test_channel_read(pattern=r"].*>") File "/home/romario/netmiko/netmiko/netmiko/base_connection.py", line 1119, in _test_channel_read return self.read_until_pattern(pattern=pattern, read_timeout=20) File "/home/romario/netmiko/netmiko/netmiko/base_connection.py", line 651, in read_until_pattern raise ReadTimeout(msg) netmiko.exceptions.ReadTimeout:

Pattern not detected: '\].*>' in output.

Things you might try to fix this:

  1. Adjust the regex pattern to better identify the terminating string. Note, in many situations the pattern is automatically based on the network device's prompt.
  2. Increase the read_timeout to a larger value.

You can also look at the Netmiko session_log or debug log for more information.

Can you help me with this problem?

bogdancordos commented 2 years ago

Hi Romario,

Thank you for your kind words. Are you using the script within your NetBox application? If so, you will need to add netmiko to the local_requirements.txt file within NetBox, usually at /opt/netbox/local_requirements.txt. I can see that you are trying to access a Mikrotik device, have you changed the "device_type" in the script from cisco_ios to mikrotik_routeros?

romarioZ1000 commented 2 years ago

Thx @bogdancordos!