Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monkey patching changes the order of commands. #3209

Open
sargon opened this issue Jun 25, 2024 · 1 comment
Open

Monkey patching changes the order of commands. #3209

sargon opened this issue Jun 25, 2024 · 1 comment

Comments

@sargon
Copy link
Contributor

sargon commented Jun 25, 2024

When monkey patching a model with clear the output is appended instead of replaced in the same spot, e.g. enterasys.rb

require 'oxidized/model/enterasys.rb'

class Enterasys
  using Refinements

  cmd 'show system hardware', clear:true do |cfg|
    cfg = cfg.each_line.reject { |line| line.match(/RPM$/) || line.match(/Uptime:/) || line.match(/LM75:/) || line.match(/Temperature:/)}.join
    comment cfg
  end
end

leads to a configuration where the system hardware informations are appended, instead of prefixed to the configuration.
When prepending (prepend:true) there are two hardware outputs in the same spot.

@Lagertonne
Copy link

Lagertonne commented Jul 19, 2024

Hi,

I had the same issue. One solution is to simply copy the whole enterasys.rb into your own model folder without using a require statement at the top and insert your own command where you want it to be in the final file. This way is also mentioned in the docs: https://github.com/ytti/oxidized/blob/master/docs/Creating-Models.md

Completely re-define an existing model by creating a file in ~/.config/oxidized/model/ with the same name as an existing model, but not require-ing the upstream model file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants