ntc-templates
ntc-templates copied to clipboard
Interface with "connected" in the description is incorrectly reported as as connected interface by cisco_ios_show_interfaces_status
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.
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.
@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
This was merged, please close issue.
Curious why these issues are not auto-closing like GH should be.