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

Interface with "connected" in the description is incorrectly reported as as connected interface by cisco_ios_show_interfaces_status #1397

Open
classicmac opened this issue Jul 15, 2023 · 2 comments

Comments

@classicmac
Copy link

classicmac commented Jul 15, 2023

ISSUE TYPE
  • Template Issue with error and raw data
TEMPLATE USING
Value PORT (\S+)
Value NAME (.+?)
Value STATUS (err-disabled|disabled|connected|notconnect|inactive|up|down|monitoring|suspended)
Value VLAN (\S+)
Value DUPLEX (\S+)
Value SPEED (\S+)
Value TYPE (.*)
Value FC_MODE (\S+)

Start
  ^Load\s+for\s+
  # Capture time-stamp if vty line has command time-stamping turned on
  ^Time\s+source\s+is
  ^-+\s*$$
  ^Port\s+Name\s+Status\s+Vlan\s+Duplex\s+Speed\s+Type -> Interfaces
  ^\s*$$
  ^. -> Error

Interfaces
  #Match fc...
  ^\s*${PORT}\s+is\s+${STATUS}\s+Port\s+mode\s+is\s+${FC_MODE}\s*$$ -> Record
  ^\s*${PORT}\s+is\s+${STATUS}\s+\(${TYPE}\)\s*$$ -> Record
  ^\s*${PORT}\s+${STATUS}\s+${VLAN}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}$$ -> Record
  ^\s*${PORT}\s+${NAME}\s+${STATUS}:\s+${VLAN}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}$$ -> Record
  ^\s*${PORT}\s+${NAME}\s+${STATUS}\s+${VLAN}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}$$ -> Record
  ^-+
  ^\s*$$
  ^. -> Error
SAMPLE COMMAND OUTPUT
Port      Name               Status       Vlan       Duplex  Speed Type
Fa0/1     *** connected to U notconnect   150          auto   auto 10/100BaseTX
SUMMARY

When an interface has the text "connected" in the interface description it is being reported as a connected interface even when the interface isn't connected.

EXPECTED RESULTS

Interface is only reported as connected when the status is connected.

ACTUAL RESULTS

Interface was reported as connected when it wasn't.

@mjbear
Copy link
Contributor

mjbear commented Aug 17, 2023

I was hoping this would be a really simple fix, but VLAN ID can't be made exclusively numeric due to trunk and routed showing up in the output.

@mjbear
Copy link
Contributor

mjbear commented Aug 17, 2023

@classicmac
Because VLAN (now VLAN_ID capture group) is a \S+ it can accidentally match other fields (after the cascade of other columns matching text in say the Name field).

This results in the below incorrect structured data.

{
	"DUPLEX": "U",
	"FC_MODE": "",
	"NAME": "***",
	"PORT": "Fa0/1",
	"SPEED": "notconnect",
	"STATUS": "connected",
	"TYPE": "150          auto   auto 10/100BaseTX",
	"VLAN": "to"
}

Changing the VLAN ID to \d+ will resolve this only when there is numeric data in the VLAN field. It is necessary to add other possible keywords (trunk and routed) as well.

Worked up PR #1449 that fixes this

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