diff --git a/CHANGELOG.md b/CHANGELOG.md index 0df90e2d1..99a77e0ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [Unreleased] + +### Added + +### Changed + +### Fixed +- powerconnect: Mask the changing temperature issue for non-stacked switches. Fixes #2088 (@clifcox) + + ## [0.32.2 – 2025-02-27] This patch release mainly fixes the docker building process, wich resulted in 0.32.1 not beeing built. diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index 7eb875649..86edac07f 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -60,7 +60,8 @@ class PowerConnect < Oxidized::Model 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) @@ -73,9 +74,22 @@ def clean(cfg) 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}) {3,}\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