netenglabs / suzieq

Using network observability to operate and design healthier networks
https://www.stardustsystems.net/
Apache License 2.0
791 stars 105 forks source link

[Feature]: Cisco NX-OS: consider xcvr interfaces down instead of not connected #930

Closed beufanet closed 5 months ago

beufanet commented 6 months ago

Suzieq version

0.22.0

Install Type

container

Feature type

other

Use case

When dealing with Cisco NX-OS, output for shutdown interface when SFP is not inserted is the following :

cisco# show interface brief
<...>
--------------------------------------------------------------------------------
Ethernet      VLAN    Type Mode   Status  Reason                   Speed     Port
Interface                                                                    Ch #
--------------------------------------------------------------------------------
Eth1/1        --      eth  routed down    XCVR not inserted          auto(D) --
Eth1/2        --      eth  routed down    XCVR not inserted          auto(D) --
Eth1/3        --      eth  routed down    XCVR not inserted          auto(D) --
Eth1/4        --      eth  routed down    XCVR not inserted          auto(D) --
Eth1/5        --      eth  routed down    XCVR not inserted          auto(D) --
Eth1/6        --      eth  routed down    XCVR not inserted          auto(D) --
Eth1/7        --      eth  routed down    XCVR not inserted          auto(D) --
Eth1/8        --      eth  routed down    XCVR not inserted          auto(D) --
Eth1/9        1       eth  trunk  up      none                        25G(D) 9
Eth1/10       --      eth  routed up      none                        25G(D) --
Eth1/11       1       eth  trunk  up      none                        25G(D) --
Eth1/12       --      eth  routed up      none                        25G(D) --

In the following line, this is considered as if the link is not connected, even if the interface is set to shutdown state.

                if entry['reason'] in ["link not connected",
                                       "xcvr not inserted"]:
                    entry['state'] = 'notConnected'

Related line : https://github.com/netenglabs/suzieq/blob/develop/suzieq/poller/worker/services/interfaces.py#L672

Proposed functionality/solution

Could it be possible to change this behavior and considered pattern matching XCVR not inserted to adminState down by default in addition to state notConnected ?

External dependencies

No response

Additional Context

beufanet commented 6 months ago

Made PR above ;)