ytti / oxidized

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

Comware: Output contains prompt and command (flapping) #1447

Closed empi89 closed 6 years ago

empi89 commented 6 years ago

I have a huge amount (>500) of HPE switches and especially the 5120 which sometimes output the prompt and command. This leads to flapping in configuration versions and flooding of hooks. e.g.:

-<SW-INT-XXX >display current-configuration
 #
  version 5.20.99, Release 2221P15
+<SW-INT-XXX>display current-configuration
 #
  version 5.20.99, Release 2221P15

I have observed that this is especially the case when the devices have some cpu load due to snmp polling. I have already changed some parts of the comware-Model to have it more reliable:

  1. removed "display version" - block (because I had the same behavior as with display current-configuration)
  2. removed "display device" - block (because I had the same behavior as with display current-configuration)
  3. replaced
    post_login 'screen-length disable'
    post_login 'undo terminal monitor'

    with

    post_login do
      send "screen-length disable\n"
      send "undo terminal monitor\n"
      expect /[cC]urrent terminal/
    end

    Because I often had the message "Info: Current terminal monitor is off." contained in the output.

For the display current-configuration I would like to implement some kind of late-filter which removes the lines starting with a prompt. However I have not found any examples how to do this in the other models. Could you please provide a hint on this? Thanks in advance!

ytti commented 6 years ago

The device obviously always shows prompt and command, right? It doesn't print them sometimes and not print sometimes? So they should be taken away by this: https://github.com/ytti/oxidized/blob/master/lib/oxidized/model/comware.rb#L18

Why isn't it working? I think it's race condition because broken model. We rely on screen-scraping prompt to know when output has ended. If we do not eat prompt when it happens, another command may consume it early and we go out of sync and cause all kind of funky issues.

Your correction makes it more broken. send doesn't expect anything, if those commands produce prompt, you have prompts in buffer which are unconsumed.

In the original model, there is same problem: https://github.com/ytti/oxidized/blob/master/lib/oxidized/model/comware.rb#L37-L43

I assume bunch of these actually produce command line, which is not consumed.

It would be safer to refactor all send away. Replace them with cmd which expects to see prompt, or if another argument is specifies, expect to see that regexp. This way we retain lock-step with output. I can't tell how to refactor the original, as I don't have the platform, but once it works with all send replaced with cmd it'll be far more robust.

no-response[bot] commented 6 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. The information that is currently in the issue is insufficient to take further action. Feel free to re-open this issue if additional information becomes available, or if you believe it has been closed in error.

berilslv commented 5 years ago

Hi guys, can someone comment this? Im facing the same issue that versions are spaming because of these lines: image Can you @ytti suggest me which lines to edit @ comware.rb ?


Found solution for HP 1920/1910. just add this line to comware.rb

if vars :ignore_disp_ver cfg.gsub! /^! Info: Current terminal monitor is off. .*/,'' Oxidized.logger.debug "Ignoring display info" end