Skip to content

Fix IOS show env power parser#2270

Merged
jvanderaa merged 6 commits intonetworktocode:masterfrom
hvanderheide:ios-power-fix
Feb 9, 2026
Merged

Fix IOS show env power parser#2270
jvanderaa merged 6 commits intonetworktocode:masterfrom
hvanderheide:ios-power-fix

Conversation

@hvanderheide
Copy link
Contributor

@hvanderheide hvanderheide commented Jan 28, 2026

On a non-PoE switch, "PoE Pwr" will display "n/a", which won't match "\w". Changed to match non-whitespace "\S". Tested on a bunch of Cisco C9300s

Also:

  • Added Error directive
  • Updated index pattern (which allows this to support older switches too)
  • Added support for some older cli output

@mjbear
Copy link
Collaborator

mjbear commented Jan 29, 2026

On a non-PoE switch, "PoE Pwr" will display "n/a", which wonn't match "\w". Changed to match non-whitespace "\S". Tested on a bunch of Cisco C9300s

Hi @hvanderheide

Thank you for your submission and fix.

There's a little bit more needed to qualify this PR ready for review and merging.

If there are any questions, please ask. Thank you!

@mjbear mjbear added the status: action required This issue requires additional information to be actionable label Jan 29, 2026
… "\w". Tested on a Cisco C9300

Add test case
@hvanderheide
Copy link
Contributor Author

There's a little bit more needed to qualify this PR ready for review and merging.

Hi @mjbear, thanks for helping me through the process. I've added a test case with both the raw output and a YAML file. The test seems to succeed.

mjbear
mjbear previously approved these changes Feb 7, 2026
@mjbear mjbear dismissed their stale review February 7, 2026 00:29

Decided to add more test data.
I will need to re-review after that.

It is possible to shorten "show environment" to "show env".
Not only that, but on older platforms it is env and not the
full word environment.
- Support trailing space after watts
- 3750x has a trailing slash number after watts (ex: 350/0)
Older switches such as 2960-S, 2960-X, and 3750G have
built-in PSUs which show up differently.
@mjbear
Copy link
Collaborator

mjbear commented Feb 7, 2026

I saw the comment from the previous contributor that is getting removed regarding "works on 3850, but not 3750". 😅

I decided to poke at some other hardware to round out the support.

😱 Oh and this is one of those (existing) templates without the Error directive.

The index pattern can be shortened to show env power all (as confirmed on a Cisco command reference).
(And likewise show env temperature for another related template.)


Here's a list of things I changed and pushed to your PR/branch.

  • Added Error directive
  • Updated index pattern (which allows this to support older switches too)
  • Added support for some older cli output

@mjbear mjbear removed the status: action required This issue requires additional information to be actionable label Feb 7, 2026
@mjbear
Copy link
Collaborator

mjbear commented Feb 7, 2026

@itdependsnetworks @jmcgill298 @jvanderaa @matt852
Could I get a second set of eyes on this PR?
(I made changes to the index which should be fine based on research, but it never hurts to have other reviewers!)

@mjbear mjbear changed the title IOS: Fix show env. power parser Fix IOS show env power parser Feb 7, 2026
@jvanderaa
Copy link
Contributor

I'm tempted that we shouldn't reduce the command length matching part. There are likely other platforms that may have a command issue there. @itdependsnetworks / @jmcgill298 I'm going to need some of your thoughts there.

@jmcgill298
Copy link
Contributor

LGTM. Even if newer versions have two different commands that start with env, then the user would have to add the fourth letter, and then that would not match the pattern in the index

@jvanderaa jvanderaa merged commit 2ad4e52 into networktocode:master Feb 9, 2026
10 checks passed
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

Successfully merging this pull request may close these issues.

4 participants