ytti / oxidized

Oxidized is a network device configuration backup tool. It's a RANCID replacement!
Apache License 2.0
2.75k stars 917 forks source link

Oxidized with Dell switch - raised Timeout::Error with msg "execution expired" and raised Oxidized::PromptUndetect with msg "unable to detect prompt: (?-mix:[#>]$) #1854

Closed Jasmine2711 closed 1 year ago

Jasmine2711 commented 5 years ago

Hi All, I am trying to collect backup for dell switch using oxidized, but etting the mentioned error. Can you please guide me to fix this.

Thanks in advance!

alexelshamouty commented 4 years ago

I have the exact same issue with an Dell S4148F @Jasmine2711 which model did you use to configure this switch with oxidized?

litewhatever commented 4 years ago

Same here, anyone has an idea how to solve this?

litewhatever commented 4 years ago

Managed to workaround this with monkey-patching ftos.rb

Following code goes into .config/oxidized/model/ftos.rb

require 'oxidized/model/ftos.rb'

class FTOS

  cfg :telnet, :ssh, clear: true do
    post_login 'terminal length 0'
    if vars :enable
      post_login do
        send "enable\n"
        send vars(:enable) + "\n"
      end
    end
    pre_logout 'exit'
  end

end

Root cause is line 41 (post_login 'terminal width 0') in ftos.rb @ytti perhaps it should be removed?

ytti commented 4 years ago

I don't have ftos, I defer judgement to any ftos user who is willing to produce pull request. Ideally that person would consider the ramifications and have dialog with involved parties. But ultimately, if it helps person making pull request, that's a win in my book, if it breaks something for someone else, well, then we'll learn about that and consider that requirement in next PR as well.

ytti commented 4 years ago

Btw. We almost never should used send it is dangerous because it doesn't expect prompt, so it can easily break prompt detection.

Here is safe alternative: https://github.com/ytti/oxidized/blob/master/lib/oxidized/model/ios.rb#L127-L134

In the ftos.rb example 'send vars(:enable)' produces prompt, which is not consumed, which means when we run next 'cmd', we may consume immediately the prompt that came from 'send vars' and consider cmd output to have ended. We no longer are 'in sync' with prompt outputting, as we thoroughly rely on seeing prompt to mean we are at end of output.

The ios.rb version consumes the prompt, and does not produce desync problem.

litewhatever commented 4 years ago

@ytti I will take it into consideration when creating PR.

acederlund commented 3 years ago

I'm seing this issue as well on older version of OS9 releases.

Below is the output from running telnet to the switch on the Oxidized server:

Trying 1.2.3.4...
Connected to 1.2.3.4.
Escape character is '^]'.
Login: admin
Password:
TOR01>en
Password:
TOR01#show version
Dell Force10 Real Time Operating System Software
Dell Force10 Operating System Version: 2.0
Dell Force10 Application Software Version: 9.2(0.0)
Copyright (c) 1999-2013 by Dell Inc. All Rights Reserved.
Build Time: Mon Jul 29 12:49:21 PDT 2013
Build Path: /sites/sjc/work/build/buildSpaces/build19/E9-2-0/SW/SRC
TOR01 uptime is 2 year(s), 16 week(s), 1 day(s), 10 hour(s), 58 minute(s)

System image file is "system://A"

System Type: S4810
Control Processor: Freescale QorIQ P2020 with 2147483648 bytes of memory.

128M bytes of boot flash memory.

  1 52-port GE/TE/FG (SE)
 48 Ten GigabitEthernet/IEEE 802.3 interface(s)
  4 Forty GigabitEthernet/IEEE 802.3 interface(s)

With debug mode activated, I can see this in the log file:

Dec 30 16:54:04 mynicehostname oxidized[8391]: 1.2.3.4 raised Oxidized::PromptUndetect with msg "unable to detect prompt: (?-mix:^([\w.@()-]+[#>]\s?)$)"
Dec 30 16:54:04 mynicehostname oxidized[8391]: /TOR1 status no_connection, retry attempt 1

As you can see, enable password is set, but it has problems detecting the prompt. This particular older release lacks the terminal width 0 feature, so I've tried removing that from the model file and restarting Oxidized. The -ssh and -telnet files are empty as well, so I'm having a hard time figuring out what output it lacks.

Tried with IRB to see if my output matched, but all seems good there as well:

irb(main):017:0> 'TOR1>'.match /^([\w.@()-]+[#>]\s?)$/
=> #<MatchData "TOR1>" 1:"TOR1>">

I tried adding prompt /^([\w.@()-]+[#>]\s?)$/ to the ftos.rb file with no luck either, and removing the terminal width 0 like I mentioned earlier.

One solution could be to upgrade the switch, as we have similar models with newer releases working with Oxidized, but they're a bit different with SSH instead of telnet, and no enable password set.

Any pointers are welcome!