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

Mask the changing temperature issue as reported in #2088. #3402

Merged
merged 12 commits into from
Feb 28, 2025
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use oxidized-web, be sure to update your oxidized-web gem to 0.15.0.
- extra/gitdiff-msteams.sh: honor the 28KB size limit and add an optional link to GitHub (@mopi3456)

### Fixed
- powerconnect: Mask the changing temperature issue for non-stacked switches. Fixes #2088 (@clifcox)
- tplink: send 'enable' before the enable password. Fixes #3271 (@robertcheramy)
- asyncos: fix prompt for hostnames containing "-" . Fixes #3327 (@robertcheramy)
- sonicos: fix prompt for hostnames containing "-" . Fixes #3333 (@robertcheramy)
Expand Down
20 changes: 17 additions & 3 deletions lib/oxidized/model/powerconnect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@

def clean(cfg)
out = []
skip_blocks = 0
len1 = len2 = skip_blocks = 0

cfg.each_line do |line|
# If this is a stackable switch we should skip this block of information
if line.match(/Up\sTime|Temperature|Power Suppl(ies|y)|Fans/i) && (@stackable == true)
Expand All @@ -71,9 +72,22 @@
skip_blocks -= 1 if /\S/ !~ line
next
end
out << line.strip
line = line.strip
# If the temps were not removed by skipping blocks, then mask them out wih XXX
# The most recent set of dashes has the spacing we want to match
if (match = line.match(/^(---+ +)(---+ +)/))
one, two = match.captures
len1 = one.length
len2 = two.length
end
# This can only be a temperature, right? ;-)
if (match = line.match(/^(\d{1,2}) +\d+ +(.*)$/))
one, two = match.captures
line = one.to_s + (' ' * (len1 - one.length)) + "XXX" + (' ' * (len2 - 3)) + two.to_s
end
out << line
end
out = out.reject { |line| line[/Up\sTime/] }
out = out.reject { |line| line[/Up\sTime/] } # Filter out Up Time
out = comment out.join "\n"
out << "\n"
end
Expand Down